From 830fa3b16ba7f36045a0941b1b64ffdbe01b34aa Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 7 May 2026 13:53:06 -0700 Subject: [PATCH] fix(v2 managed agents): type stream_events as a sync def returning AsyncIterator --- litellm/managed_agents/adapters/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/litellm/managed_agents/adapters/base.py b/litellm/managed_agents/adapters/base.py index 1cbf299b2c9..ce4b941c71d 100644 --- a/litellm/managed_agents/adapters/base.py +++ b/litellm/managed_agents/adapters/base.py @@ -75,7 +75,7 @@ class SandboxAdapter(Protocol): """ ... - async def stream_events( + def stream_events( self, sandbox_url: str, opencode_session_id: str, @@ -88,6 +88,14 @@ class SandboxAdapter(Protocol): normalized `(event_type, data_dict)` tuples per contract §7. Events not in the translation table are dropped. Raises `SandboxUnreachableError` on connect/timeout failures. + + NOTE: this is declared as a regular ``def`` returning an + ``AsyncIterator`` because concrete adapters implement it as an + ``async def ... yield`` (async generator). An ``async def f() -> + AsyncIterator[T]: yield x`` is typed as ``AsyncIterator[T]``, + not ``Coroutine[..., AsyncIterator[T]]`` — declaring the + protocol method as ``async def`` would force callers to ``await`` + it before iterating, which is the wrong runtime shape. """ ...