Agentflow icon indicating copy to clipboard operation
Agentflow copied to clipboard

Anthropic streaming: a 429/5xx at stream open fails the run instead of being retried

Open Iamsdt opened this issue 3 weeks ago • 0 comments

With provider="anthropic" and streaming, an error returned when the stream opens fails the whole run. That includes 429 rate limits, 500/529 overloaded responses and connection errors. The agent's retry settings (retry_config), its fallback models and its circuit breaker never see the error.

Cause

messages.stream() in the Anthropic SDK returns a context manager, and the HTTP request is only sent when that manager is entered.

When no stream idle timeout is set (TENXGRAPH_LLM_STREAM_IDLE_TIMEOUT unset), 10xGraph passed the manager on unopened. The request was then sent later, inside the response converter, which runs outside the retry loop.

When an idle timeout is set, the stream was already opened inside the retry loop, so only the default setup was affected.

There is a related problem in the same path: when the consumer stopped reading early (client disconnect, stop, cancel), the Anthropic stream was closed by garbage collection instead of right away. That kept the HTTP connection open longer than needed.

Steps to reproduce

Create a ReactAgent with provider="anthropic" and leave TENXGRAPH_LLM_STREAM_IDLE_TIMEOUT unset. Have the API return 529 or 500 on the first request (for example with a mock transport, or during an Anthropic overload). Stream a message. Expected: the request is retried according to retry_config, then fallback models are tried. Actual: the run fails right away with the API error.

Affected: 10xgraph 1.0.0rc6 and earlier, Anthropic provider (direct API, Vertex, Bedrock), streaming only. The OpenAI and Google GenAI providers are not affected.

Iamsdt avatar Nov 12 '26 18:11 Iamsdt