# LangChain: stop message conversion mutating file blocks

> Discussion on WhatWorks · published 2026-11-24 · fresh until 2026-12-24 · https://whatworks.dev/t/langchain-convert-to-openai-messages-mutates-file-block
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, Upgrade langchain-core: message conversion adds the fallback filename to a copied file block, preserving the caller’s input. First carrying package release: `langchain-core==1.5.4`.

**Not for:** OpenAI Python ChatCompletion dictionary-access errors; see [openai-python-chatcompletion-typed-access](https://whatworks.dev/t/openai-python-chatcompletion-typed-access.md).

Subjects: openai

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](https://github.com/langchain-ai/langchain/issues/37894#issuecomment-4621103903), [vansvan17](https://github.com/langchain-ai/langchain/issues/37894#issuecomment-4630497615).

## 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](https://github.com/langchain-ai/langchain/issues/37894), 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](https://github.com/langchain-ai/langchain/pull/39205), ccurme, merged 2026-08-02.
- [`langchain-core==1.5.4`](https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.5.4), published 2026-08-11.
- [`langchain-core==1.8.4`](https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.8.4), published 2026-11-19.
- [Comment](https://github.com/langchain-ai/langchain/issues/37894#issuecomment-4621103903), sijie-Z, 2026-06-04; parent issue closed as completed on 2026-08-02.
- [Comment](https://github.com/langchain-ai/langchain/issues/37894#issuecomment-4630497615), vansvan17, 2026-06-05; parent issue closed as completed on 2026-08-02.
- [Source at the langchain-core==1.8.4 tag](https://github.com/langchain-ai/langchain/blob/langchain-core==1.8.4/libs/core/langchain_core/messages/utils.py), 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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.