buzz icon indicating copy to clipboard operation
buzz copied to clipboard

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

Open iammienta opened this issue 3 months ago • 2 comments

Any agent I run on the buzz-agent runtime with a DeepSeek model works for exactly one exchange. The moment a turn needs a second round-trip it 400s, and it does that every time.

The provider says why:

Agent reported error (code -32000): llm: (deepseek-v4-pro) 400 Bad Request:
{"error":{"message":"The `reasoning_content` in the thinking mode must be passed back to the API.",
"type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

In thinking mode DeepSeek requires reasoning_content from the assistant message to be included when you continue the conversation. buzz-agent doesn't send it back.

How often

79 times over two days, on two seats I run independently:

  • deepseek-v4-flash, 37 failures, 2026-08-08 10:16 through 2026-08-09 12:45
  • deepseek-v4-pro, 42 failures, 2026-08-08 10:34 through 12:47

Not flaky. Every continuation fails.

Setup

Buzz 0.5.5, macOS 26.5.2, Apple Silicon. buzz-agent runtime, openai-compatible provider, BUZZ_AGENT_THINKING_EFFORT set.

What I ruled out first

Authentication failures are a separate code, -32001 llm auth: Authentication Fails, and they stopped once my credentials were right while these carried on. The two seats have independent config. -pro and -flash behave identically, so it isn't one model or one bad setup.

Why it matters

A seat that fails on continuation can't hold any role that takes more than one exchange, so review and anything iterative are out. Retries bill per token, so every failure costs money and produces nothing.

One note if you reproduce this from the logs: the lines carry ANSI escapes inside the key=value pairs, so grep 'outcome="error"' returns zero on a log full of errors. Strip them first.

sed $'s/\x1b\[[0-9;]*m//g' <log> | grep 'reasoning_content'

iammienta avatar Aug 09 '26 14:08 iammienta

Still present on 0.5.17, and here is the read/write asymmetry that causes it.

Confirmation on a newer build and a different platform. Windows 11, Buzz Desktop 0.5.17 (binaries dated 2026-08-18), buzz-agent runtime, deepseek-v4-pro, OpenAI-compatible provider. 29 identical failures across two days: 2026-08-18 03:49–05:02 and 2026-08-19 02:43–03:28 UTC. Every logged agent_returned for that seat is outcome="error"; the other three seats on the same instance (Claude, Codex, GLM) have zero. Ten days and several releases after this report, on a different OS.

The mechanism, at f88cda9. Buzz does read the field — parse_openai prefers reasoning_content explicitly, with a comment naming DeepSeek (crates/buzz-agent/src/llm.rs:1488), and lands it in LlmResponse.reasoning.

The loss is on the way back out. HistoryItem::Assistant carries only text, tool_calls, and reasoning_details, and the request builder serializes only reasoning_details (llm.rs:742-750). That field is populated on exactly one path — Provider::OpenRouter, via parse_openai_with_reasoning_details (llm.rs:115) — so for a direct DeepSeek endpoint it is always None.

So LlmResponse.reasoning has no return path at all. It is used for the observer feed (agent.rs:623-631) and then dropped. The right field is read and then discarded, because the only reasoning field with a write path is the OpenRouter-specific one.

Also confirming your ANSI note — the escapes sit inside the key=value pairs and grep 'outcome="error"' returns zero on a log full of them. The sed you gave works.

uevuleocha avatar Aug 20 '26 07:08 uevuleocha

Still present on 0.5.18 (binaries dated 2026-08-21), macOS arm64, buzz-agent runtime, OpenAI-compatible provider. That is one build newer than @uevuleocha's 0.5.17 confirmation above.

Reporting again because today I hit both halves of #4773 in a single afternoon, on two different DeepSeek seats in the same channel — which I think makes the case that these are one defect, not two:

Seat Model Error
Deepseek-pro deepseek-v4-pro The reasoning_content in the thinking mode must be passed back to the API.
Deepseek-flash deepseek-v4-flash This model does not support image

That maps exactly onto #4773's two changes — reasoning_content replay, and image_url gating for text-only providers. Neither seat is misconfigured; pro runs BUZZ_AGENT_THINKING_EFFORT=max, flash runs high.

The reasoning_content failure is not new here either — my logs carry 55 occurrences on that seat, the first at 2026-08-08T10:34:44Z, a day before I opened this issue.

The part I had not reported: a single poison event escalates into silent message loss

This is worse than a failed turn, and it is the reason I am commenting rather than waiting.

When the 400 fires, the batch is requeued with backoff — and each retry absorbs newly-arrived messages into the same permanently-failing batch:

attempt=1 max=10 delay_secs=4.22   events=1
attempt=2 max=10 delay_secs=8.37   events=1
attempt=3 max=10 delay_secs=16.44  events=1
attempt=4 max=10 delay_secs=33.35  events=1
attempt=5 max=10 delay_secs=69.71  events=2   <- a new message joins a batch that cannot succeed
attempt=6 max=10 delay_secs=142.67 events=2
attempt=7 max=10 delay_secs=247.60 events=2
attempt=8 max=10 delay_secs=260.15 events=3
attempt=9 max=10 delay_secs=254.55 events=4

The poison is still in the batch on every retry, so it can never drain. Sixteen minutes elapsed here, and the loop only ended because the process restarted — the batch was never delivered.

When it does reach attempt=10, everything in it is discarded together. From the same seat's log on an earlier run:

ERROR buzz_acp::queue: dead-lettering batch after 10 retries — discarding 1 events

So one unsupported content part can take an unbounded number of unrelated, well-formed messages down with it, and the senders get no signal at all — the messages simply never arrive. On a multi-agent run that is indistinguishable from an idle agent, which is expensive to diagnose.

Suggestion

Beyond #4773's provider capability gating, it would help if a batch that fails with a non-retryable 4xx were isolated on first failure rather than retried ten times with accumulation — either fail that single event and drain the rest, or stop admitting new events into a batch that has already failed once. The capability fix stops this particular poison; batch isolation stops the next one.

Happy to supply full logs for either seat.

iammienta avatar Aug 22 '26 20:08 iammienta