Skip to content

Commit 31a8837

Browse files
committed
fixup! feat(model-routing): MODEL_ALIASES and cross-provider rotation
Await _execute_streaming() in CrossProviderExecutor.execute() so callers receive the async generator instead of an unawaited coroutine. Fixes: #58
1 parent 3968d27 commit 31a8837

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

.fork/features/model-routing.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# model-routing — MODEL_ALIASES and Cross-Provider Rotation
2+
3+
## 2026-06-23 — Fix streaming coroutine not awaited in CrossProviderExecutor
4+
5+
Target: `feat(model-routing): MODEL_ALIASES and cross-provider rotation`
6+
Files:
7+
- `src/rotator_library/client/cross_provider_executor.py`
8+
9+
Working commits before autosquash:
10+
- (see fixup commit hash after commit)
11+
12+
Verification:
13+
- `uv run python3 -m py_compile src/rotator_library/client/cross_provider_executor.py` — passed
14+
- `uv run ruff check src/rotator_library/client/cross_provider_executor.py --select F401,F811,F821,E9` — passed
15+
16+
Notes:
17+
- `CrossProviderExecutor.execute()` returned `self._execute_streaming(...)` without
18+
`await`. Since `_execute_streaming` is `async def` (returns a coroutine wrapping the
19+
inner `_stream_with_failover()` async generator), callers received a coroutine object
20+
instead of the async generator. The Anthropic `/v1/messages` streaming wrapper then
21+
failed with `'async for' requires an object with __aiter__ method, got coroutine`.
22+
- Fix: `return await self._execute_streaming(...)` so the coroutine resolves to the
23+
inner async generator before being returned to the caller.
24+
- Ref: https://github.com/b3nw/LLM-API-Key-Proxy/issues/58

src/rotator_library/client/cross_provider_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def execute(
8282
)
8383

8484
if is_streaming:
85-
return self._execute_streaming(
85+
return await self._execute_streaming(
8686
canonical_model, available_targets, retry_mode,
8787
request, pre_request_callback, **kwargs,
8888
)

0 commit comments

Comments
 (0)