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

ChatDeepSeek With Use_responses_api=True Raises KeyError('Messages')

ChatDeepSeek._get_request_payload() unconditionally accesses payload['messages'], but Responses API payloads use 'input'. Additionally, streaming does not delegate to Responses streaming methods. This causes all invoke/ainvoke/stream/astream calls to fail before any HTTP request.

highConfidence 92%Langchainlangchain-coreVector StoresAffected V1.1.0

Origin Analysis

The DeepSeek override of _get_request_payload assumes a Chat Completions payload containing 'messages'. When use_responses_api (or output_version='responses/v1') is enabled, BaseChatOpenAI._get_request_payload returns a Responses payload with 'input', so the key lookup raises KeyError. The class also does not override _stream/_astream to route to _stream_responses/_astream_responses.
Install langchain-deepseek 1.1.0 with langchain-openai 1.5.2a1. Run: from langchain_deepseek import ChatDeepSeek model = ChatDeepSeek(model='deepseek-v4-flash', api_key='test', base_url='https://example.invalid/v1', use_responses_api=True) model.invoke('Reply exactly OK') Observe KeyError: 'messages' before any HTTP request. The same occurs with stream(), ainvoke(), and astream().

Fixing Code Block

Edge Case Audit

This fix assumes that ChatDeepSeek's only normalization is removing the 'name' field. If your version includes additional message cleanups, preserve them inside the 'messages' guard. The streaming overrides must exactly match the base class method signatures or upgrade of langchain-openai may break. After applying, Responses API requests will reach DeepSeek's endpoint; if DeepSeek does not truly support the Responses API, you will get a server-side 4xx/5xx instead of a client-side KeyError, which is expected but still requires model support. Rollback by removing the added methods and reverting _get_request_payload to its original unconditional loop.

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