Skip to content

fix(buzz-agent): replay reasoning_content for DeepSeek thinking mode - #5487

Open
olympusbuildz wants to merge 1 commit into
block:mainfrom
olympusbuildz:fix/buzz-agent-replay-reasoning-content-5399
Open

fix(buzz-agent): replay reasoning_content for DeepSeek thinking mode#5487
olympusbuildz wants to merge 1 commit into
block:mainfrom
olympusbuildz:fix/buzz-agent-replay-reasoning-content-5399

Conversation

@olympusbuildz

@olympusbuildz olympusbuildz commented Aug 10, 2026

Copy link
Copy Markdown

Problem

DeepSeek seats on buzz-agent with thinking mode fail on every continuation:

400 Bad Request: The `reasoning_content` in the thinking mode must be passed back to the API.

Reporter saw 79 hard failures across deepseek-v4-flash/pro in two days (#5399). Iterative tool-using roles break; retries burn tokens for nothing.

Root cause

Step What happens on main
Parse parse_openai correctly reads message.reasoning_contentLlmResponse.reasoning
UI/ACP Thought chunks emit that string
History HistoryItem::Assistant only stored OpenRouter reasoning_detailsplain reasoning dropped
Replay openai_body never wrote reasoning_content back

DeepSeek docs (thinking mode): for requests that carry tools, prior assistant reasoning_content must be fully passed back or the API 400s.

Fix

  1. Add reasoning: String on HistoryItem::Assistant (keep reasoning_details).
  2. Persist response.reasoning at every assistant history push.
  3. In openai_body, emit reasoning_content when non-empty.
  4. Charge reasoning.len() in estimated bytes.

Single concern — no image_url gating, no provider feature work.

Why not #4773

block/buzz#4773 targets the same class but is stale vs current HistoryItem (reasoning_details era), bundles supports_image_url, emits only when that message has tool_calls, and has no unit tests. This PR is main-current, #5399-only, tested.

Closest PR search: #4773 (related), #3403 / #4332 (different). none found that closes #5399 on current main with tests.

Test plan

cargo test -p buzz-agent --lib reasoning_content
cargo test -p buzz-agent --lib
  • openai_body_omits_reasoning_content_when_empty
  • parse_openai_captures_reasoning_content
  • openai_body_replays_reasoning_content_on_plain_assistant_when_present
  • openai_body_replays_reasoning_content_on_tool_call_assistant
  • Full buzz-agent lib suite 484 passed @ head 49fc467 (rebased on current main)
  • Full monorepo just ci not run for this change (package lib gate only)

Risk / blast radius

  • In scope: buzz-agent history + OpenAI-compat request body only
  • Not changed: provider feature flags, image_url gating, non-OpenAI transports

Fixes #5399

Retested after rebase onto current main @ 49fc46796.

Acceptance retest (2026-08-18)

Rebased onto current main. Mini proof @ 7dd78e177: cargo test -p buzz-agent --lib reasoning_content — 4/4.

@olympusbuildz
olympusbuildz marked this pull request as ready for review August 11, 2026 13:14
@olympusbuildz
olympusbuildz requested a review from a team as a code owner August 11, 2026 13:14
@olympusbuildz
olympusbuildz force-pushed the fix/buzz-agent-replay-reasoning-content-5399 branch from 0b8db76 to 6e5938a Compare August 11, 2026 13:14
@olympusbuildz
olympusbuildz force-pushed the fix/buzz-agent-replay-reasoning-content-5399 branch 6 times, most recently from b984126 to 8a5e00b Compare August 21, 2026 16:13
DeepSeek thinking mode returns 400 on any continuation that carries tools
when prior assistant turns omit reasoning_content. parse_openai already
extracted the field into LlmResponse.reasoning (and ACP thought chunks
emitted it), but HistoryItem::Assistant only kept OpenRouter-style
reasoning_details — the plain string was dropped before openai_body ran.

Persist reasoning on Assistant history and echo it as reasoning_content
whenever non-empty. Harmless on plain multi-turn (API ignores it); required
for tool loops per DeepSeek docs.

Fixes block#5399

Related (stale / multi-concern, not stacked): block#4773

Co-authored-by: Olympusbuildz <Olympus.roots@outlook.com>
Signed-off-by: Olympusbuildz <Olympus.roots@outlook.com>
@olympusbuildz
olympusbuildz force-pushed the fix/buzz-agent-replay-reasoning-content-5399 branch from 8a5e00b to aa20c20 Compare August 22, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buzz-agent: DeepSeek seats fail every follow-up turn, reasoning_content is not sent back

1 participant