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

Content Block Corruption When Using Type File

Accessing message.content_blocks inside a chat model start callback raises TypeError because the legacy v0 file block conversion passes the block's 'id' both explicitly and via **extras to create_file_block.

highConfidence 95%Langchain-CoreRetrieversEmbeddingsChat ModelsAffected V1.4.6

Origin Analysis

In langchain_core.messages.block_translators.langchain_v0._convert_legacy_v0_content_block_to_v1, the file block branch builds an extras dictionary that contains the 'id' key while simultaneously passing id explicitly to create_file_block. This causes Python to raise 'got multiple values for keyword argument "id"'.
Instantiate ChatOpenAI with a custom AsyncCallbackHandler that accesses message.content_blocks in on_chat_model_start. Send a HumanMessage built with create_file_block. The callback triggers conversion of legacy v0 file blocks, hitting the duplicate id argument and raising TypeError.

Fixing Code Block

Edge Case Audit

The fix preserves id by passing it explicitly and filtering it from extras. Ensure that any downstream code that expected id to be only in **extras is unaffected. The function is stateless, so concurrency is safe, but other legacy v0 block types may have similar duplicate id patterns and should be audited. Rollback: revert this function to the original implementation if callback regressions or unexpected id handling are observed.

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