fix(acp): preserve usage and terminal evidence on timeout - #1080
Conversation
|
Thanks @Galius5136 — your A/B review on #1051 directly shaped this narrower implementation. This PR keeps the useful cancel-first ACP behavior while addressing the regressions you identified:
The result is limited to preserving genuine ACP cancellation evidence and usage without changing verifier or sandbox behavior. |
|
Thermo-nuclear review at exact head The cooperative timeout path works in the normal case: I ran a real Docker The function waits for A direct probe reproduced this with a 0.5 s cleanup budget: There is a simpler ownership model here:
Please add a regression where |
|
Addressed in
Regression covers immediate cancel failure + delayed terminal usage. Old code fails test. Validation: affected suite |
|
Thank you, @bingran-you! Addressed your concerns, but deferred runtime.py extraction. |
|
Thermo-nuclear exact-head follow-up at The cancellation race is closed and the lifecycle is now decomposed into A fresh real native-Claude OAuth Docker run at this exact head executed I wrote the extraction/final repair during this review, so this still requires an independent maintainer review of the exact SHA before squash merge under the repository policy. |
Summary
Fixes #933.
ACP wall/idle deadlines previously cancelled the local
ACPClient.prompt()task without invoking the existingACPClient.cancel()method. That prompt task owns the sole ACP response reader, so BenchFlow discarded available cancellation-time evidence:PromptResponse.usage;session/updatetool events;Timed-out native ACP runs could therefore report
total_tokens=0,usage_source=unavailable, and leave tool calls pending.Fix
session/cancelattempt before hard local cancellation.disconnect()clears the live session.The deadline remains a timeout even when the peer cooperates. BenchFlow preserves genuine peer evidence; it does not convert cancellation into success or synthesize terminal state or token counts.
Prior work
This change is independently implemented from current
main.session/canceland remains unmerged. Standard ACPusage_updatereports context occupancy rather than cumulative consumed-token totals.sandbox_user=None, and verifier regressions; it was closed unmerged.This PR keeps only the narrow ACP runtime and usage-lifecycle fix. It does not change verifier behavior, sandbox hardening, publication policy, diagnostics schemas, provider routing, dependencies, or streamed-usage parsing.
Regression coverage
Tests use protocol-shaped JSON-RPC through the real
ACPClientreader and cover:Validation
No live provider or sandbox rollout was run.
Limitation
For cooperative agents returning
PromptResponse.usage, this timeout accounting gap is fully fixed.Agents that omit
PromptResponse.usagemay still reporttotal_tokens=0withusage_source=unavailable. This is intentional and honest: BenchFlow has no reliable native token total to preserve and does not invent one.Provider-routed runs may still obtain usage through separate LiteLLM telemetry. Native subscription agents that omit final usage remain affected.
This is not a merge blocker. A follow-up should add another evidence source only if real traces show important supported agents routinely omit
PromptResponse.usageafter cancellation.