Skip to main content

Module bridge

Module bridge 

Source
Expand description

ACP EventSink bridge: translates AgentEvents into session/update notifications pushed through an mpsc channel.

The server creates one AcpBridge per session turn, injects it as the EventSink for that session’s [AgentRuntime], and drains the receiver after each session/prompt call to write notifications to stdout.

§MessageId strategy (S2-C6, S2-C8)

The bridge buffers AgentEvent::PartialToken deltas internally. When AgentEvent::TurnFinished arrives, it computes a content-hash messageId (SHA-256 first 12 hex chars of the full accumulated text) and emits every buffered chunk with the same messageId. The final notification carries stopReason, messageId, and the completed message content. This satisfies:

  • S2-C6: all chunks share one messageId.
  • S2-C8: messageId is a stable content hash.
  • S2-C7: the final notification includes the completed message.

§Tool call notifications (Sprint 3)

Tool calls follow the lifecycle:

  1. tool_call with status pending (inc. locations)
  2. tool_call_update with status in_progress (synthesised by bridge)
  3. tool_call_update with status completed or failed (on ToolResult)

Per-call state tracking supports concurrent tool calls arriving and completing out-of-order (S3-C7).

Structs§

AcpBridge
An EventSink that translates agent events into ACP session/update JSON-RPC notification Values and pushes them into an mpsc channel.

Functions§

extract_locations
Extract ToolCallLocation entries from tool arguments.
sha256_first_12
Compute the SHA-256 hash of text and return the first 12 hex characters. This is stable: identical input always produces the same output.