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

Missing Initial <Think> Tag In Streamed LangGraph Messages For MiniMax M2.5 Reasoning Models

When using stream_mode=['messages'] with MiniMax M2.5 via langchain-openai, the first reasoning token (<think>) is stored in additional_kwargs['reasoning_content'] with an empty content field. LangGraph's message accumulation only concatenates content, so the opening tag is omitted from the final AIMessage, while the closing </think> tag remains.

highConfidence 86%LangchainVector StoresRetrieversMemoryAffected Vlangchain==1.2.13Affected Vlangchain-Core==1.2.21Affected Vlangchain-Openai==1.1.12Affected Vlanggraph==1.1.3

Origin Analysis

langchain-openai's _convert_delta_to_message_chunk places reasoning_content in additional_kwargs instead of content when the API delta carries only reasoning_content and no content. LangGraph's add_messages reducer merges message chunks by concatenating their content fields, so an initial empty-content chunk with reasoning_content='<think>' contributes nothing to the final content.
1. Create a LangChain agent with ChatOpenAI(model='MiniMax-M2.5', base_url=...). 2. Invoke agent.stream(state, stream_mode=['messages','updates'], version='v1'). 3. Observe yielded message chunks and final Graph State: the opening <think> tag is absent while </think> is present.

Fixing Code Block

Edge Case Audit

This is a provider-specific hotfix; do not apply globally to all OpenAI-compatible models because it would force reasoning_content into content for models like DeepSeek where such content is intentionally kept separate. If you monkeypatch the base ChatOpenAI class instead of using the subclass, concurrent requests may observe the patched behavior even for other models. Rollback: revert to the original ChatOpenAI class; no state migration is needed because only in-memory chunk conversion is affected.

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