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

ChatOpenAI/ChatAnthropic: Default Request_timeout=None Disables SDK Timeout Causing Infinite Hangs

LangChain passes None as timeout to OpenAI/Anthropic SDKs, which interpret None as explicitly no timeout, bypassing SDK default 600s read timeout and causing indefinite HTTP hangs.

highConfidence 95%LangchainRetrieversVector StoresMemoryAffected Vlangchain-Openai 1.1.10Affected Vlangchain-Anthropic 1.3.4Affected Vlangchain-Openai <=1.1.10Affected Vlangchain-Anthropic <=1.3.4

Origin Analysis

LangChain uses None as 'not configured' for request_timeout and passes it unchanged to client_params['timeout']. The SDKs distinguish between NOT_GIVEN (apply default) and None (explicit no timeout); since LangChain always passes a value, the SDK default is never applied, and httpx.Timeout(None) disables all timeouts.
1. Create ChatOpenAI() or ChatAnthropic() without setting request_timeout. 2. Inspect model_fields default: request_timeout is None. 3. In validate_environment, client_params = {'timeout': None}. 4. openai.OpenAI(timeout=None) or anthropic.Anthropic(timeout=None). 5. SDK checks is_given(None) -> True, so uses None instead of SDK default. 6. httpx.Timeout(None) -> no connect/read/write/pool timeout. 7. Under network drop or server delay, request blocks forever; only kill -9 recovers.

Fixing Code Block

Edge Case Audit

This change makes it impossible for users to explicitly disable timeouts by setting request_timeout=None (since Pydantic cannot distinguish unset from explicit None). Users with very long-running generations that previously relied on no timeout will now hit SDK's 600s read timeout and receive ReadTimeout errors. Also, if users set 0 expecting no timeout, the OpenAI fix will pass timeout=0 (which httpx treats as immediate timeout); the Anthropic fix omits 0, applying default timeout instead. The proper fix should use a sentinel like NOT_GIVEN or a separate flag to distinguish 'unset' from explicit None. Rollback: revert the patch or set request_timeout to a very large value manually. No concurrency-specific issues, but async and sync clients both affected.

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