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

AIMessageChunk Content Empty And Thinking Tokens Missing When Streaming VLLM Model With Enable_thinking

When streaming from a vLLM instance exposing Gemma with thinking enabled via ChatOpenAI, reasoning tokens are returned as empty-content AIMessageChunks because ChatOpenAI's delta parser only handles delta.content and drops delta.reasoning_content. This loses all thinking tokens and produces many empty chunks.

highConfidence 85%Langchainlangchain-coreAgents

Origin Analysis

ChatOpenAI._convert_delta_to_message_chunk only reads d.get("content") for message content; vLLM/DeepSeek reasoning models return reasoning in delta.reasoning_content (or thinking), which is ignored, resulting in empty AIMessageChunk with additional_kwargs={}.
1. Run vLLM server with google/gemma-4-31B-it and enable thinking. 2. Instantiate ChatOpenAI with base_url pointing to vLLM and extra_body={"chat_template_kwargs": {"enable_thinking": True}}. 3. Wrap in create_deep_agent and stream with stream_mode including "messages". 4. Observe multiple AIMessageChunk objects with content='' and no reasoning data; final content appears only at the end.

Fixing Code Block

Edge Case Audit

This hotfix relies on internal LangChain method _convert_delta_to_message_chunk, which may change signature across versions. Storing reasoning in additional_kwargs is non-standard and may be ignored by some consumers; if you need reasoning in content, consider a different approach. Pin langchain-openai version and test concurrency; revert by removing the subclass if errors occur.

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