Skip to content

feat(acp): wire AcpContext into agent loop, cancellation, spec compliance#814

Merged
bug-ops merged 5 commits intomainfrom
epic/acp-context-wiring
Feb 24, 2026
Merged

feat(acp): wire AcpContext into agent loop, cancellation, spec compliance#814
bug-ops merged 5 commits intomainfrom
epic/acp-context-wiring

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Feb 24, 2026

Summary

  • Wire AcpContext (IDE-proxied FS, shell, permissions) through AgentSpawner into agent tool chain via CompositeExecutor (ACP-first, local fallback)
  • Add cancel_signal: Arc<Notify> to LoopbackHandle for cooperative cancellation between ACP sessions and agent loop
  • Fix permission cache key collision on anonymous tools (use tool_call_id fallback)
  • Return StopReason::Cancelled when IDE sends session/cancel (ACP spec compliance)
  • Map ToolOutput to structured SessionUpdate::ToolCall with proper ToolKind and Completed status instead of generic AgentMessageChunk (ACP spec compliance)

Changes

File Change
src/main.rs spawn_acp_agent accepts Option<AcpContext>, composes ACP executors
crates/zeph-tools/src/executor.rs DynExecutor newtype for object-safe ToolExecutor composition
crates/zeph-tools/src/lib.rs Re-export DynExecutor
crates/zeph-core/src/channel.rs cancel_signal: Arc<Notify> on LoopbackHandle
crates/zeph-core/src/agent/builder.rs with_cancel_signal() builder method
crates/zeph-acp/src/agent.rs Cancel signal in SessionEntry, StopReason::Cancelled, structured ToolCall notifications, tool_kind_from_name()
crates/zeph-acp/src/permission.rs Cache key fallback to tool_call_id when title is None

ACP spec compliance fixes

  • NC-1: prompt() uses tokio::select! to detect cancel_signal during drain loop, returns StopReason::Cancelled per spec requirement
  • NC-2: Tool output maps to SessionUpdate::ToolCall with Completed status and ToolKind per tool-calls spec, enabling IDE structured tool UX

Test plan

  • 2564 tests passed, 0 failed (+10 new tests)
  • cargo clippy --workspace -- -D warnings: 0 warnings
  • cargo +nightly fmt --check: clean
  • DynExecutor delegation tests (4 tests)
  • with_cancel_signal() pointer identity test
  • cancel_signal notify/await tests (2 tests)
  • Permission cache key fallback test
  • ToolOutput maps to ToolCall with correct kind/status
  • tool_kind_from_name mapping coverage

Closes #779, closes #780
Part of Epic #777

Pass AcpContext (IDE-proxied FS, shell, permissions) through AgentSpawner
into the agent tool chain via CompositeExecutor composition. ACP executors
take priority over local tools with automatic fallback.

Add cancel_signal (Arc<Notify>) to LoopbackHandle for cooperative
cancellation between ACP sessions and the agent loop. cancel() now
triggers notify_one() to interrupt the active prompt.

Closes #779, closes #780
@bug-ops bug-ops added this to the ACP Phase 2 milestone Feb 24, 2026
@bug-ops bug-ops added enhancement New feature or request acp Agent Client Protocol integration labels Feb 24, 2026
Add ACP Phase 2 entries to CHANGELOG.md (AcpContext wiring, DynExecutor,
cancel_signal, permission cache fix). Update mdbook architecture and
advanced sections. Create zeph-acp README. Update zeph-core and
zeph-tools READMEs with new public API surface.
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 24, 2026
@bug-ops bug-ops linked an issue Feb 24, 2026 that may be closed by this pull request
6 tasks
…ol output

Two spec compliance fixes:

1. prompt() now detects cancel_signal via tokio::select! during the
   drain loop and returns StopReason::Cancelled instead of EndTurn.
   Per ACP spec: agents MUST return cancelled stop reason when the
   client sends session/cancel.

2. LoopbackEvent::ToolOutput now maps to SessionUpdate::ToolCall with
   Completed status and proper ToolKind instead of AgentMessageChunk.
   Per ACP spec: tool invocations must be reported via structured
   ToolCall notifications, not as generic message chunks.
@github-actions github-actions bot added size/XL and removed size/L labels Feb 24, 2026
@bug-ops bug-ops changed the title feat(acp): wire AcpContext into agent loop, add cancellation propagation feat(acp): wire AcpContext into agent loop, cancellation, spec compliance Feb 24, 2026
@bug-ops bug-ops enabled auto-merge (squash) February 24, 2026 14:45
@bug-ops bug-ops merged commit 312e0f4 into main Feb 24, 2026
23 checks passed
@bug-ops bug-ops deleted the epic/acp-context-wiring branch February 24, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

acp Agent Client Protocol integration core documentation Improvements or additions to documentation enhancement New feature or request rust size/XL

Projects

None yet

1 participant