Skip to content

feat(buzz-agent): emit agent_thought_chunk for reasoning content#1436

Merged
wpfleger96 merged 2 commits into
mainfrom
duncan/buzz-agent-thought-emit
Jul 1, 2026
Merged

feat(buzz-agent): emit agent_thought_chunk for reasoning content#1436
wpfleger96 merged 2 commits into
mainfrom
duncan/buzz-agent-thought-emit

Conversation

@wpfleger96

Copy link
Copy Markdown
Collaborator

buzz-agent never emitted agent_thought_chunk, so the observer feed showed no Thinking block even with a reasoning model. goose, claude, and codex all emit it. This closes the parity gap.

What changed

crates/buzz-agent/src/types.rs — Add pub reasoning: String to LlmResponse. Empty string means no reasoning (consistent with the text field style).

crates/buzz-agent/src/llm.rs — Populate reasoning in all three provider parse paths:

  • parse_responses: collect summary[].text from type == "reasoning" output items (Responses API)
  • parse_anthropic: collect thinking from type == "thinking" content blocks (extended thinking)
  • parse_openai: always String::new() — chat/completions does not expose reasoning tokens

crates/buzz-agent/src/agent.rs — Before emitting agent_message_chunk, emit agent_thought_chunk when response.reasoning is non-empty. Thought precedes message, matching goose/claude/codex wire order.

crates/buzz-acp/src/acp.rs — Fix two stale comments claiming session_info_update is goose-only; buzz-agent has always emitted it too (lib.rs:510).

crates/buzz-agent/tests/golden_transcripts.rs — Three new end-to-end tests using the credential-free fake LLM harness:

  • test_thought_chunk_emitted_before_message_chunk_anthropic — Anthropic provider, thinking block → thought chunk precedes message chunk
  • test_thought_chunk_emitted_before_message_chunk_responses_api — OpenAI Responses API, reasoning item → thought chunk precedes message chunk
  • test_no_reasoning_no_thought_chunk — plain text response → no thought chunk emitted

Related: #1412

npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 and others added 2 commits July 1, 2026 14:20
buzz-agent never emitted agent_thought_chunk, so the observer feed's
Thinking block was always absent even with a reasoning model — unlike
goose/claude/codex which all emit it.

Add a `reasoning` field to `LlmResponse` and populate it in all three
provider parse paths:
- Responses API: concatenated summary[].text from type=="reasoning" items
- Anthropic: concatenated thinking blocks (type=="thinking")
- OpenAI chat/completions: always empty (reasoning not exposed)

Emit agent_thought_chunk before agent_message_chunk in agent.rs when
reasoning is non-empty. Tests cover both the Anthropic and Responses API
paths and verify no thought chunk is emitted for plain text responses.

Also fix two stale comments in acp.rs claiming session_info_update is
goose-only; buzz-agent emits it too (lib.rs:510).

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Per Thufir review pass 1:

1. parse_openai now extracts reasoning_content (DeepSeek) and reasoning
   (other compat hosts) from the message object. OPENAI_COMPAT_API=auto
   routes non-openai.com hosts to chat/completions, so self-hosted
   reasoning models (DeepSeek, vLLM) now emit agent_thought_chunk.

2. Fix remaining stale acp.rs struct-field doc (active_run_id field):
   was 'Goose-specific / other agents will never populate this'. Now
   correctly states goose AND buzz-agent both emit session_info_update
   with _meta.goose.activeRunId; other agents may leave it unset.

3. cargo fmt --all (golden_transcripts.rs:610 assert_eq! wrap).

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96 wpfleger96 merged commit 9f2a11b into main Jul 1, 2026
29 checks passed
@wpfleger96 wpfleger96 deleted the duncan/buzz-agent-thought-emit branch July 1, 2026 18:57
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.

1 participant