AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

RunnableSequence Silently Swallows Exceptions In Async Streaming Path

When a step inside RunnableSequence raises an exception during astream(), the exception is caught internally and the stream closes without surfacing the error to the caller. Sync stream() and async ainvoke() propagate correctly; only the async streaming path is affected.

highConfidence 89%LangchainMemoryVector Storeslangchain-core

Origin Analysis

The async streaming implementation of RunnableSequence (likely in langchain_core/runnables/base.py) contains a try/except block that catches exceptions from intermediate steps and silently returns or breaks instead of re-raising, causing the generator to stop without notifying the consumer.
1. Create a RunnableSequence with at least two steps, where a non-first step raises an exception when invoked. 2. Call chain.astream(input) and iterate over the async generator. 3. Observe that the stream ends silently without raising, while chain.stream(input) and chain.ainvoke(input) both raise the exception.

Fixing Code Block

Edge Case Audit

This change may break callers that have come to rely on the silent behavior, as they might not expect an exception to be raised mid-stream. Users should update their error handling to catch exceptions during astream() iteration. In concurrent scenarios (e.g., multiple streams via asyncio.gather), one stream raising may cancel others; consider using return_exceptions or per-task handling. When rolling back to a previous version, the bug will reappear, so maintain test coverage for exception propagation.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state