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

OpenAI Responses Image Content Blocks Do Not Support File_id Inputs

The OpenAI Responses block translator in langchain-core raises ValueError when converting image blocks with file_id or legacy id source types, even though the Responses API supports input_image.file_id.

mediumConfidence 88%Langchain-CoreAgentsVector StoresEmbeddingsAffected V1.4.0

Origin Analysis

In langchain_core.messages.block_translators.openai.convert_to_openai_data_block, the responses branch for ImageContentBlock only handles source types 'url' and 'base64', raising ValueError for 'file_id' and legacy 'id'. This is an incomplete implementation of the OpenAI Responses API input_image schema.
1. Import convert_to_openai_data_block and create_image_block from langchain_core.messages. 2. Create block = create_image_block(file_id='file-abc123'). 3. Call convert_to_openai_data_block(block, api='responses'). 4. Observe ValueError: Unsupported source type. Only 'url' and 'base64' are supported.

Fixing Code Block

def _convert_image_block_to_responses(block: ImageContentBlock) -> dict: source = block['source'] source_type = source.get('type') if source_type == 'url': return {'type': 'input_image', 'image_url': source['url']} if source_type == 'base64': media_type = source.get('media_type', 'image/jpeg') data = source['data'] image_url = f'data:{media_type};base64,{data}' return {'type': 'input_image', 'image_url': image_url} if source_type == 'file_id': return {'type': 'input_image', 'file_id': source['file_id']} if source_type == 'id': return {'type': 'input_image', 'file_id': source['id']} raise ValueError( 'Unsupported image source type: ' + source_type + '. Only url, base64, file_id, and id are supported for Responses API.' )
Adds explicit branches for source types 'file_id' and legacy 'id' in the Responses image translator, returning the OpenAI Responses payload {'type': 'input_image', 'file_id': ...}. The existing url and base64 branches are preserved, and the Chat Completions path remains untouched.

Edge Case Audit

The change assumes the file_id is valid and accessible at runtime; the OpenAI Responses API may still reject the payload with 400/404 if the file has expired or belongs to a different organization. The function is pure and stateless, so no concurrency or threading issues are introduced. Rollback: revert the modified function or pin langchain-core to a version without this change. If existing users were passing unsupported source types, they will now receive the new ValueError listing supported types, which is more informative but could surface unexpected failures.

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