Repository navigation
Description
Symptom
In a chat conversation on a durable environment: send a message, let the turn start streaming tool calls, press Stop, then type a follow-up and send it into the same chat. The follow-up is never processed — the conversation ends failed with
executor: acp session/prompt: Invalid params: session already has active run `run_<uuid>`; use _goose/unstable/session/steer
and the message the user just typed is lost. The session stays unusable for as long as the abandoned run keeps executing, which is unbounded (a run blocked on a tool, or on a tool-permission request whose client is gone, never ends on its own).
Evidence from the deployment
paca 0.19.2, goose 1.50.1, agent paca-planner, durable environment conversation:
agent_conversations:7ca6cf25-f02b-4095-a357-72179ca0410a,trigger_type=chat_message,status=failed,error_message= the line above,environment_idset.- Its event log is one conversation with two turns:
user_messageat 14:39:25 (turn 1 then streamed ~4,375agent_thought_chunk/tool_callevents),user_messageat 14:42:08,environment_readyat 14:42:10 — and noturn_endfor turn 1, i.e. turn 1 was stopped, not finished. - The run id in the error is the one turn 1 started: the
session_info_updateat 14:39:38 carries_meta.goose.activeRunId = run_58072af2-5693-44d0-b5f4-b2420dd531ad.
Why the code cannot already handle it
services/agent-runner/internal/acp/client.go: Prompt stops waiting when its context is cancelled and returns ctx.Err() as a clean stop; its own doc comment says the run is not cancelled ("this transport has no session/cancel call"). That was true of the goose this client was originally verified against; goose 1.50.1 has it.
In goose (crates/goose/src/acp/server.rs), start_active_run rejects a second session/prompt for a session whose active_prompt_runs entry still exists — that is this error, with the "use _goose/unstable/session/steer" hint — and only on_cancel, the session/cancel notification, clears it by cancelling the run's token. Every abandon path in the runner reaches this state: a user Stop (the reported case), the timeout_minutes turn budget, and the maxToolCalls cap. So a conversation killed by its own timeout cannot be continued either, until that abandoned run ends.
apps/acp-bridge's Runner.Interrupt already cancels at the ACP level first (client.Cancel → session/cancel) and only kills the subprocess after a grace period. The executor path has no equivalent.
Measured against the live deployment
Probe of a running paca-env-… pod (goose 1.50.1), driving /acp directly:
session/promptwith asleep 60tool call in flight, then a secondsession/prompt→{"code":-32602,"message":"Invalid params","data":"session already has active runrun_53acf805-3b1f-4120-956c-58f60ed48f29; use _goose/unstable/session/steer"}— exact reproduction.session/cancel(notification, POST answered202) → the nextsession/prompton that session succeeded 3.8 s later, and the abandoned turn's own terminal frame reportedstopReason: "cancelled".
So the race window for a follow-up sent right after Stop is a few seconds, not "however long the run happens to keep going" — which is why the fix below also retries once.
Proposed fix
Client.Promptcancels on every exit that did not receive the turn's terminal response: a newnotify(JSON-RPC without an id — the shape goose'son_cancelis registered for, the same oneapps/acp-bridge'sCancelsends) pluscancelRun. A stop then ends the run instead of orphaning it; turn timeouts and the tool-call cap get the same treatment.- If
session/promptis rejected because the previous run is still unwinding, cancel and send that prompt once more after a short delay, so a message typed immediately after Stop is not lost.
Acceptance criteria
- Stopping a turn ends its run: a new message in the same chat afterwards is processed instead of failing with
session already has active run. - No
session/cancelfollows a turn that ended normally (a chat conversation reuses the same session across turns). - A prompt rejected by an active run is retried exactly once and succeeds, its events streamed/persisted once.
Unit tests (fail on the pre-fix behaviour): TestPrompt_CancelledSendsSessionCancel — reverted, it reports session/cancel sent 0 times, want exactly 1; TestPrompt_RetriesOnceAfterActiveRunRejection — reverted, it returns Prompt: Invalid params: session already has active run …; TestPrompt_SuccessSendsNoSessionCancel.
Activity
pullfrog commentedon Oct 28, 2026