[PR #4155] Consolidate ACP Tool Call Events from 3 to 2 #10885

Closed
opened 2026-02-16 18:15:38 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4155

State: closed
Merged: No


Consolidate ACP Tool Call Events from 3 to 2

Summary

Reduce tool call event emissions from 3 events (pending → running → completed) to 2 events (running → completed) by removing the redundant pending event.

Problem

Currently, we send 3 ACP events per tool call:

  • pending: tool_call event with no input parameters (empty {})
  • running: tool_call_update event with the actual input parameters
  • completed: tool_call_update event with results

The pending event provides no useful information since part.state.input is empty by design, creating unnecessary noise in the ACP event stream.

Root Cause Analysis

The pending event has no input content by design. In src/session/prompt.ts:1076, when the "tool-input-start" event occurs, the tool part is created with:

state: {
  status: "pending",
  input: {},  // Empty object - no parameters yet
  raw: "",
}

The input parameters are only populated when the tool transitions to "running" status. This means:

  • pending state: Tool is queued, but part.state.input is empty ({})
  • running state: Tool is executing, part.state.input contains actual parameters

In src/acp/agent.ts, when we receive the pending event via this.config.sdk.event.subscribe, the part.state.input field is empty.

Conclusion: The pending event is inherently empty and provides no useful information beyond the tool ID. The original 2-event approach (skip pending, only send running + completed) is correct.

Solution

Skip the pending state and only emit 2 events:

  • running: tool_call event with input parameters and status: "in_progress"
  • completed: tool_call_update event with results

Changes

In src/acp/agent.ts:150-165:

  • Add break in pending case (no-op)
  • Consolidate tool call emission into running case with actual input parameters
  • Send status: "in_progress" instead of separate pending/running events

Testing

Tested with the latest version of Zed and it works.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4155 **State:** closed **Merged:** No --- # Consolidate ACP Tool Call Events from 3 to 2 ## Summary Reduce tool call event emissions from 3 events (pending → running → completed) to 2 events (running → completed) by removing the redundant pending event. ## Problem Currently, we send 3 ACP events per tool call: - **pending**: `tool_call` event with no input parameters (empty `{}`) - **running**: `tool_call_update` event with the actual input parameters - **completed**: `tool_call_update` event with results The pending event provides no useful information since `part.state.input` is empty by design, creating unnecessary noise in the ACP event stream. ## Root Cause Analysis The pending event has no input content by design. In `src/session/prompt.ts:1076`, when the "tool-input-start" event occurs, the tool part is created with: ```typescript state: { status: "pending", input: {}, // Empty object - no parameters yet raw: "", } ``` The input parameters are only populated when the tool transitions to "running" status. This means: - **pending state**: Tool is queued, but `part.state.input` is empty (`{}`) - **running state**: Tool is executing, `part.state.input` contains actual parameters In `src/acp/agent.ts`, when we receive the pending event via `this.config.sdk.event.subscribe`, the `part.state.input` field is empty. **Conclusion**: The pending event is inherently empty and provides no useful information beyond the tool ID. The original 2-event approach (skip pending, only send running + completed) is correct. ## Solution Skip the pending state and only emit 2 events: - **running**: `tool_call` event with input parameters and `status: "in_progress"` - **completed**: `tool_call_update` event with results ## Changes In `src/acp/agent.ts:150-165`: - Add `break` in pending case (no-op) - Consolidate tool call emission into running case with actual input parameters - Send `status: "in_progress"` instead of separate pending/running events ## Testing Tested with the latest version of Zed and it works.
yindo added the pull-request label 2026-02-16 18:15:38 -05:00
yindo closed this issue 2026-02-16 18:15:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10885