Repository navigation
fix(acp): answer open permission requests as cancelled on cancel - #14406
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the "no caller passes an explicit Suggestions
[DESIGN-REVIEWED] 1eb6935 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the declared exclusion: That is the one counted sibling of the root cause (2 Inventory (5 items) — 5 justifiedIntent: FIX — Stop with an open tool approval should end the turn at once on goose and pi, not wait 10 s and kill the harness.
[FIRST-PRINCIPLES-REVIEWED] 1eb6935 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/acp/client.py:12812 -- False positive or not applicable? A repository writer can comment: |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsOne advisory finding; nothing blocks the merge. FINDING — src/kiro_crew/acp/client.py:12806 — [OPUS-REVIEWED] 1eb6935 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
UX Review (Fable 5) — ⏭️ skippedRevision |
ebde388 to
106073f
Compare
|
Maintainer sweep (2026-09-27, on behalf of @bolichen97): every gate was green on 106073f, but the branch went |
ACP requires the client to answer every pending session/request_permission with the cancelled outcome after it sends session/cancel. goose and pi hold a cancelled turn open until that answer arrives, so a Stop from a surface that had not rejected the open approval first waited out the whole ack budget and hard-killed the harness process. Each cancelled approval gets one SEL record before the answers go out.
106073f to
1eb6935
Compare
Problem / Motivation
Goal: Pressing Stop while a tool approval is open ends the turn right away on goose and pi, instead of waiting 10 seconds and killing the harness.
On goose and pi, a Stop that arrives while a permission request is still unanswered is never acknowledged. The turn waits out the whole soft-stop budget (
agent.soft_stop_budget_secs, 10 s by default). Then Crew hard-kills the harness process and respawns it. The dashboard does not hit this, because its Stop rejects the open approval first. Slack's Stop does not, so it takes this path.Why it matters
Stop is a basic control. On these two backends it cost a 10-second hang and a process kill every time an approval was open. The conversation survives, because the respawn resumes the session, but the Stop still feels broken.
Not a goal
What changed (motivation → approach → change)
Symptom: goose and pi never acknowledge a
session/cancelwhile asession/request_permissionis open, so Stop falls through to a hard kill.Root cause: the ACP spec says that after it sends
session/cancel, the client MUST answer every pending permission request with thecancelledoutcome.AcpClient.cancel_sessionsent the cancel and nothing else. opencode and deepseek acknowledge anyway. goose and pi wait for the answer, which never came.Change:
AcpClient.cancel_sessioninsrc/kiro_crew/acp/client.pynow answers every request still in_permission_optionswithcancelledafter the cancel is written. That map holds the unanswered requests:reject_toolandapprove_tool's usual path pop their entry, and each new turn clears it. The map is emptied as the answers go out, so nothing is answered twice. Each cancelled approval is a denial Crew made, so it gets its own SEL record (outcome=rejected_on_cancel) before the answers go out. All the records are written in one off-loop hop with a time limit, so a stuck audit backend costs a Stop at most one audit timeout. The cancellation section ofdocs/system-specs/modules/acp-client.mdnow says this. A cancelled pi gate dialog is recorded as denied, the same as a rejection, so pi's gate tripwire still holds. The kiro runtime path (AcpSessionHandle) is untouched.Backwards compatibility
Compatible: the only new wire traffic is a
cancelledanswer to a request that was otherwise left open, and only after the turn is already being cancelled.Tests
test/test_acp_goose_backend.py::test_a_cancel_answers_the_open_permission_request_as_cancelled: replays goose's live permission frame, cancels, and checks three things: thesession/cancelis followed by exactly onecancelledanswer for that request id, onerejected_on_cancelSEL record is written for it off the event loop thread, and a second cancel sends nothing more.test/test_acp_pi_backend.py::test_a_cancel_answers_the_open_gate_dialog_as_cancelled: the same check against pi's live gate-dialog frame.Both fail on
origin/mainand pass with the fix. The related suites also pass (979 tests):test_acp_client,test_acp_turn_state_parity,test_deny_bounded_write,test_acp_provider_cov80, and the goose and pi backend files.Manual verification
A live drive against real harnesses (goose 1.52.0, pi 0.87.1 with pi-acp, opencode 1.18.32, dsh 0.1.5-rc.3) and a local fake model. The drive opens a tool approval, leaves it unanswered, and calls
SessionManager.stop_turn, which is what Slack's Stop does:In every run, the next message continued the same session.
Related Issues
N/A. Found while checking the multi-turn lifecycle of the opencode / pi / goose / deepseek ACP backends.
Pattern harvest
Not generalizable:
cancel_sessionis the one place this client sendssession/cancel.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)