You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: openAI request error : [The reasoning_content in the thinking mode must be passed back to the API.] #3246
Category: bug | Module: agentscope-extensions-model-openai | Status: Needs info (verified against main @ ed77530a4)
What we checked, and what we found
The report implies the framework replays history without the reasoning_content that thinking mode requires. That specific mechanism does not hold in the current code:
OpenAIMessageConverter.convertAssistantMessage(...) (formatter/OpenAIMessageConverter.java:314-345) takes the message's first ThinkingBlock and sets builder.reasoningContent(...), plus reasoning_details from block metadata, and serializes tool_calls independently (:363+). So a thinking + tool-call assistant message does emit both fields on replay.
Thinking is retained where replay needs it: OpenAIResponseParser maps inbound reasoning_content/reasoning_details into ThinkingBlock, ReasoningContext.buildFinalMessage() keeps thinking + text + tool calls in one assistant Msg, and AgentState.toJson()/fromJsonString() persist polymorphic content blocks including ThinkingBlock.
Sub-agent output does not create parent assistant messages (it is flattened into tool results), so the sub-agent suspicion does not point at an obvious serialization hole.
DeepSeekFormatter.applyDeepSeekFixes(...) (formatter/DeepSeekFormatter.java:97+) is the component that implements exactly the rule the error message cites — keep reasoning_content for segments with tool calls, strip it otherwise.
One real code gap found while verifying (separate from your error, worth a maintainer look)
OpenAIChatModel formats the request through the options-aware entry point — formatter.format(messages, effectiveOptions) (OpenAIChatModel.java:129) → AbstractBaseFormatter.format(msgs, options) → doFormat(msgs, options). But OpenAIChatFormatter overrides doFormat(List<Msg>, GenerateOptions) with its own body (formatter/OpenAIChatFormatter.java:68) instead of delegating to doFormat(List<Msg>), and DeepSeekFormatter overrides only the single-argument version (formatter/DeepSeekFormatter.java:68). Result: on the HTTP chat-completions path the DeepSeek post-processing (applyDeepSeekFixes, which is precisely the "keep reasoning_content for tool-call segments / drop it elsewhere" rule, plus name stripping and the empty-user tail fix) is never applied. Note this gap would produce the opposite symptom (stale reasoning_content sent where it should be removed), so it is unlikely to be the direct cause of your error message — but it means provider-specific shaping is silently skipped on the main request path, which is its own defect. Two identically named DeepSeekFormatter classes exist (formatter/ and compat/deepseek/, the latter wired by DeepSeekModelProvider), which makes this easy to miss.
What we need to pin your intermittent failure (please attach)
Model name + base URL + the thinking/reasoning parameters being sent.
Whether context compaction (or a sub-agent) had already run in that session before the failing turn — compaction rewrites history and is the remaining candidate for an assistant message losing its ThinkingBlock while keeping tool_calls.
From the attached request JSON, the index of the offending message: a non-first assistant message that has tool_calls (or plain content) but no reasoning_content, and whether a content: "" field is present. That one message distinguishes "history rewriting dropped the thinking block" from "the endpoint expects stricter semantics than the OpenAI-compatible DTO models".
Your trimmed OpenAIRequest attachment is precisely what is needed; the code evidence alone is not enough to close this as a framework defect, which is why this is marked needs info rather than confirmed.
Activity
jujn commentedon Sep 22, 2026
as-java 哪个版本呢?
joman-jiang commentedon Sep 22, 2026
我用的开发版,正式版不超过2.0.3
oss-maintainer commentedon Sep 22, 2026
Issue Evaluation
Category:
bug| Module:agentscope-extensions-model-openai| Status: Needs info (verified againstmain@ed77530a4)What we checked, and what we found
The report implies the framework replays history without the
reasoning_contentthat thinking mode requires. That specific mechanism does not hold in the current code:OpenAIMessageConverter.convertAssistantMessage(...)(formatter/OpenAIMessageConverter.java:314-345) takes the message's firstThinkingBlockand setsbuilder.reasoningContent(...), plusreasoning_detailsfrom block metadata, and serializestool_callsindependently (:363+). So a thinking + tool-call assistant message does emit both fields on replay.OpenAIResponseParsermaps inboundreasoning_content/reasoning_detailsintoThinkingBlock,ReasoningContext.buildFinalMessage()keeps thinking + text + tool calls in one assistantMsg, andAgentState.toJson()/fromJsonString()persist polymorphic content blocks includingThinkingBlock.DeepSeekFormatter.applyDeepSeekFixes(...)(formatter/DeepSeekFormatter.java:97+) is the component that implements exactly the rule the error message cites — keepreasoning_contentfor segments with tool calls, strip it otherwise.One real code gap found while verifying (separate from your error, worth a maintainer look)
OpenAIChatModelformats the request through the options-aware entry point —formatter.format(messages, effectiveOptions)(OpenAIChatModel.java:129) →AbstractBaseFormatter.format(msgs, options)→doFormat(msgs, options). ButOpenAIChatFormatteroverridesdoFormat(List<Msg>, GenerateOptions)with its own body (formatter/OpenAIChatFormatter.java:68) instead of delegating todoFormat(List<Msg>), andDeepSeekFormatteroverrides only the single-argument version (formatter/DeepSeekFormatter.java:68). Result: on the HTTP chat-completions path the DeepSeek post-processing (applyDeepSeekFixes, which is precisely the "keepreasoning_contentfor tool-call segments / drop it elsewhere" rule, plusnamestripping and the empty-user tail fix) is never applied. Note this gap would produce the opposite symptom (stalereasoning_contentsent where it should be removed), so it is unlikely to be the direct cause of your error message — but it means provider-specific shaping is silently skipped on the main request path, which is its own defect. Two identically namedDeepSeekFormatterclasses exist (formatter/andcompat/deepseek/, the latter wired byDeepSeekModelProvider), which makes this easy to miss.What we need to pin your intermittent failure (please attach)
io.agentscope:*version, and whether it predates fix(ollama): surface thinking output as a ThinkingBlock #3146 (that PR changed how thinking is surfaced as aThinkingBlock).ThinkingBlockwhile keepingtool_calls.tool_calls(or plain content) but noreasoning_content, and whether acontent: ""field is present. That one message distinguishes "history rewriting dropped the thinking block" from "the endpoint expects stricter semantics than the OpenAI-compatible DTO models".Your trimmed
OpenAIRequestattachment is precisely what is needed; the code evidence alone is not enough to close this as a framework defect, which is why this is marked needs info rather than confirmed.Automated evaluation by github-manager-bot
amyaxy commentedon Sep 22, 2026
@joman-jiang 可以提供一个可以复现的案例代码吗
joman-jiang commentedon Sep 22, 2026
oss-maintainer commentedon Sep 22, 2026
amyaxy commentedon Sep 23, 2026
@jujn 我来跟下这个问题
fix(deepseek): pass reasoning_content back for all assistant turns (a…