fix(acp): emit tool output content in ToolCallUpdate for all execution paths#1006
Merged
fix(acp): emit tool output content in ToolCallUpdate for all execution paths#1006
Conversation
…n paths (#1003) Two bugs prevented tool results from appearing in ACP tool call blocks in Zed: - Remove `if !already_streamed` guard in native tool-call path so `LoopbackEvent::ToolOutput` is emitted unconditionally; TUI dedup is handled by the TUI channel's own event forwarder, not here. - Generate stable UUID `tool_call_id` in fenced-block execution paths, emit `ToolStart` before `send_tool_output`, and pass the same ID to both calls — eliminating orphaned `ToolCallUpdate` events with empty ID. Add regression tests: - `handle_tool_result_sends_output_when_streamed_true`: verifies `send_tool_output` is called when `already_streamed = true` (GAP-1) - `handle_tool_result_fenced_emits_tool_start_then_output_via_loopback`: verifies ToolStart precedes ToolOutput with matching non-empty UUID (GAP-2) Closes #1003
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1003
Problem
When using Zeph as an ACP agent in Zed, tool call blocks showed no result content. Other ACP agents (e.g. Claude Agent) correctly display tool output inside the tool block.
Root Cause
Two bugs in
crates/zeph-core/src/agent/tool_execution.rs:Bug 1 — streaming tools skipped
send_tool_outputWhen
already_streamed = true(bash, shell tools),LoopbackEvent::ToolOutputwas never emitted. The ACP layer (loopback_event_to_updates) needs this event to produceToolCallUpdatewith content — without it the tool block in Zed stayed empty.Bug 2 — fenced-block path passed empty
tool_call_idEmpty ID with no preceding
ToolStartproduced orphanedToolCallUpdateevents the ACP client could not match to any tool block.Fix
if !already_streamedguard —send_tool_outputis now called unconditionally. TUI deduplication is handled by the TUI channel's own event forwarder.tool_call_idbefore execution, emitsend_tool_startwith it, pass the same ID tosend_tool_output. Applied to both theOk(Some)andConfirmationRequiredsub-paths.Tests
handle_tool_result_sends_output_when_streamed_true— regression test for Bug 1handle_tool_result_fenced_emits_tool_start_then_output_via_loopback— verifies ToolStart precedes ToolOutput with matching non-empty UUIDChecklist
cargo +nightly fmt --checkcleancargo clippy --workspace -- -D warningscleancargo nextest run --workspace --lib --bins2944/2944 passedzeph-core,zeph-acp)advanced/acp.md,advanced/tools.md,advanced/channels.md)