You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Track F-HIGH #5 from ROADMAP.md.
## Problem
`extras/acp/mod.rs:229-231` used a single `last_tool_call_id:
Option<ToolCallId>` slot to pair `AgentEvent::ToolResult` with
its originating `AgentEvent::ToolCall`. When the LLM dispatched
N parallel tool calls (Anthropic + OpenAI both support this),
each new `ToolCall` clobbered the previous slot. The first N-1
results ended up paired with an empty id, breaking client-side
correlation.
Phase 3 already plumbed `id: CompactString` through both events
from rig's `tool_call.id` / `tool_result.id`. The ACP bridge was
discarding it (`AgentEvent::ToolCall { id: _, ... }`).
## Fix
New `ToolCallCorrelator` struct with two buckets:
- `by_id: HashMap<String, ToolCallId>` — provider-supplied rig
ids (Anthropic, OpenAI). `record(rig_id, acp_id)` inserts;
`resolve(rig_id)` removes + returns the original acp_id.
- `fifo: VecDeque<ToolCallId>` — fallback for providers that
emit empty ids. `record("", acp_id)` pushes; `resolve("")` pops.
rig emits results in dispatch order, so FIFO is correct here.
`run_prompt` now uses the correlator for both record + resolve.
Stub-empty acp_id only on stray-result edge cases that
shouldn't happen with rig's stream.
Extracted into its own struct (not just `HashMap` + `VecDeque`
locals) so the F5 fix is unit-testable without standing up a
full ACP server.
## Tests
Four new tests in `extras::acp::tests`:
- `correlator_matches_parallel_tool_calls_by_id`: two ids
recorded, resolve in reverse order — both pair correctly.
- `correlator_uses_fifo_for_empty_rig_ids`: empty-id calls
resolve in dispatch order.
- `correlator_separates_id_and_fifo_buckets`: mixed-mode
doesn't cross-contaminate.
- `correlator_returns_none_for_unknown_id`: stray result is a
None, not a panic.
658 pass (unchanged total — F5 only adds extras-feature tests).
All build profiles clean.
Co-authored-by: Yogthos <yogthos@gmail.com>
0 commit comments