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

Convert_to_openai_image_block Drops The Detail Field For Image Content Blocks

The OpenAI image block translators in langchain-core discard the 'detail' field when it is stored in 'extras' or 'metadata', causing image resolution/detail settings to be lost in Chat Completions and Responses API payloads.

highConfidence 95%Langchain-CoreEmbeddingsMemory

Origin Analysis

convert_to_openai_image_block and convert_to_openai_data_block only read the detail from the top level of the image block (e.g., block['detail']) while ignoring common alternative locations such as block['extras']['detail'] and block['metadata']['detail']; therefore the detail parameter is not forwarded to the OpenAI API.
1. Create an image content block with detail inside 'extras' or 'metadata', e.g. {"type": "image", "url": "https://example.com/img.png", "extras": {"detail": "high"}}. 2. Call langchain_core.messages.block_translators.openai.convert_to_openai_image_block on the block. 3. Observe the returned image_url object lacks the detail field.

Fixing Code Block

Edge Case Audit

During upgrade or rollback, keep the original functions available or pin langchain-core to a version containing the fix. If 'detail' appears in multiple locations with different values, the precedence (top-level > extras > metadata) could change behavior; ensure this matches existing serialization conventions. Monkey-patching these functions globally in a multi-threaded environment is safe because they are pure, but multiple patches or version mismatches may lead to inconsistent outputs. Rollback: restore the previous module source or downgrade langchain-core to the last unaffected release.

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