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

ChatOpenAI Silently Drops Provider-Specific Tool-Call Fields, Breaking Multi-Turn Tool Calls On Compatible Endpoints

ChatOpenAI's message conversion discards unknown fields on tool calls (e.g., Gemini's thought_signature) in both directions, causing later provider-side 400 errors in multi-turn tool calling loops.

highConfidence 90%LangChainVector StoresAgentsChainsAffected V1.1.9Affected V1.6.x

Origin Analysis

In langchain_openai.chat_models.base, _convert_dict_to_message calls parse_tool_call(...) which only keeps id/type/function, and _lc_tool_call_to_openai_tool_call reconstructs only those keys during serialization. The original raw tool_call dict is not preserved anywhere, so provider-specific extras are unrecoverable.
1. Use langchain-openai 1.1.9+ with an OpenAI-compatible endpoint that returns a tool call with an extra field such as 'thought_signature'. 2. Call _convert_dict_to_message on the raw assistant response containing that tool_call. 3. Convert the resulting AIMessage back with _convert_message_to_dict. 4. Observe that the extra field is absent from the outgoing tool_call dict, leading to provider 400 on the next turn.

Fixing Code Block

Edge Case Audit

This patch will forward unknown tool-call fields to the next endpoint. If a message created from one provider is replayed to a different provider (e.g., official OpenAI), the unknown fields may cause a 400 error. Users switching between providers should clear/rebuild messages or gate the forwarding based on the endpoint. Rollback: revert the changes; no data migration is needed. Additional care: ensure extra values are JSON-serializable and do not contain sensitive information that should not be echoed.

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