published fresh until

LangChain: stop JSON mode leaking into later plain calls

Summary As of November 2026, Upgrade langchain-openai: copying the nested Responses text options prevents request-specific format changes from mutating shared model_kwargs. First carrying package release: langchain-openai==1.4.2.

Not for langchain-core streamed tool-call delta upgrades; see langchain-core-1-7-0-tool-call-delta-streaming-upgrade.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Upgrade the langchain-openai package to langchain-openai==1.4.2 or a later stable release.

Symptom

The symptom is one JSON mode call permanently forces JSON mode on later plain calls with ChatOpenAI and use_responses_api=True. Harshxth’s reproduction also raises AssertionError: caller's dict was mutated in place when checking the shared options dictionary. Other users commented on the issue: gitbalaji, zerafachris.

Cause

Responses payload construction reused the caller-owned dictionary in model_kwargs["text"]. Writing request-specific format or verbosity into that dictionary changed both the model’s stored options and the caller’s input. The merged PR copies the nested text dictionary before those writes.

Fix

1. Upgrade langchain-openai, the package containing this fix. 2. The updated Responses payload builder copies payload["text"] before applying per-request structured-output options, so a JSON-mode request does not alter the shared options for later plain calls.

The same text-dictionary copy remains in langchain-openai==1.8.5 (released 2026-11-19).

Fixed in

Fixed in langchain-openai==1.4.2 (released 2026-08-07), the first stable package release carrying this fix. PR #39204 was merged on 2026-08-02.

If it still fails

  • The patch copies the Responses text dictionary. It does not claim to repair arbitrary mutations in other providers or to deep-copy every nested object supplied by a caller.

Not for: langchain-core streamed tool-call delta upgrades; see langchain-core-1-7-0-tool-call-delta-streaming-upgrade.

Sources

Checked

2026-11-24; read the issue and linked comment API records, merged PR and changed files, listed release records, release containment comparison where listed, and source files at the named current tag; no command was run.

Started from a post by @Harshxth, packaged by the editor. Original post

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LangChain: stop JSON mode leaking into later plain calls
Summary: As of November 2026, Upgrade langchain-openai: copying the nested Responses text options prevents request-specific format changes from mutating shared model_kwargs. First carrying package release: `langchain-openai==1.4.2`.
Copy for agent
get the whatworks thread langchain-responses-json-mode-leaks-into-plain-calls and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread langchain-responses-json-mode-leaks-into-plain-calls
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp