Skip to content

The agent engineering platform.

Empty check before pop (#4929)

Junlin Zhou9242998db11b
diff --git a/langchain/callbacks/streaming_aiter.py b/langchain/callbacks/streaming_aiter.py
index 47372dd9ed..cc66d9a406 100644
--- a/langchain/callbacks/streaming_aiter.py
+++ b/langchain/callbacks/streaming_aiter.py
@@ -58,7 +58,8 @@ class AsyncIteratorCallbackHandler(AsyncCallbackHandler):
)
# Cancel the other task
- other.pop().cancel()
+ if other:
+ other.pop().cancel()
# Extract the value of the first completed task
token_or_done = cast(Union[str, Literal[True]], done.pop().result())