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

Responses API: Parsed_arguments Leaks From ParsedResponseFunctionToolCall Into AIMessage Content, Breaking The Next Turn

When using ChatOpenAI with output_version='responses/v1' and structured output plus tools, the second turn of a ReAct loop fails because the AIMessage content block contains an unexpected 'parsed_arguments' field, which OpenAI rejects as an unknown parameter.

highConfidence 95%Langchain-OpenaiAffected V1.1.12Affected V1.2.2

Origin Analysis

In langchain_openai/chat_models/base.py, _construct_lc_result_from_responses_api serializes OpenAI response objects using plain model_dump(exclude_none=True, mode='json'), which does not honor the OpenAI SDK's __api_exclude__ attribute. This causes the client-side-only parsed_arguments field to be included in AIMessage content blocks and subsequently sent back in the next request, where the API rejects it.
1. Create a ChatOpenAI instance with output_version='responses/v1'. 2. Bind a structured output schema (method='json_schema', strict=True) along with a tool call. 3. Invoke the runnable with a user message that triggers a tool call; the first turn succeeds. 4. Re-send the returned raw AIMessage along with the tool result as the input for the second turn. 5. The request fails with a 400 error citing unknown parameter 'input[N].parsed_arguments'.

Fixing Code Block

Edge Case Audit

If a model has a __api_exclude__ attribute that is not a set of strings, pydantic may raise an error; consider converting to a set or validating the type. Also, if other code relies on the previously leaked fields being present in AIMessage content, this change removes them and could break downstream consumers. Rolling back is straightforward: revert the three calls to the original model_dump. Test with both responses/v1 and chat completions paths to ensure no regressions.

Ecosystem Topology