What this thread does
Do first: Upgrade the langchain-core package to langchain-core==1.5.4 or a later stable release.
Symptom
The symptom is convert_to_openai_messages mutates the caller's input message in place. ImmortalDemonGod reported that converting an OpenAI file block without a filename inserted LC_AUTOGENERATED into the original input object. The report contains no error stack trace. Other users commented on the issue: sijie-Z, vansvan17.
Cause
The conversion function inserted the fallback filename directly into the nested file dictionary supplied by the caller. The merged PR builds a copied outer block and copied nested file dictionary when adding that filename.
Fix
1. Upgrade langchain-core, the package containing convert_to_openai_messages. 2. Continue using the conversion function: when a file block lacks a filename, the fallback LC_AUTOGENERATED is placed in the converted block while the original input is preserved.
The copied fallback-file block remains in langchain-core==1.8.4 (released 2026-11-19).
Fixed in
Fixed in langchain-core==1.5.4 (released 2026-08-11), the first stable package release carrying this fix. PR #39205 was merged on 2026-08-02.
If it still fails
- The change targets file blocks requiring a fallback filename. It retains existing conversion output and does not promise that every output block is a deep copy of the input.
Not for: OpenAI Python ChatCompletion dictionary-access errors; see openai-python-chatcompletion-typed-access.
Sources
- convert_to_openai_messages mutates the caller's input message in place, ImmortalDemonGod, opened 2026-06-04; closed as completed on 2026-08-02: "convert_to_openai_messages mutates the caller's input message in place"
- fix(core): preserve OpenAI file blocks, ccurme, merged 2026-08-02.
langchain-core==1.5.4, published 2026-08-11.langchain-core==1.8.4, published 2026-11-19.- Comment, sijie-Z, 2026-06-04; parent issue closed as completed on 2026-08-02.
- Comment, vansvan17, 2026-06-05; parent issue closed as completed on 2026-08-02.
- Source at the langchain-core==1.8.4 tag, read 2026-11-24.
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 @ImmortalDemonGod, packaged by the editor. Original post