Repository navigation
feat(bridge): enhance Interrupt method to support pause functionality… - #706
Conversation
… and update related tests
There was a problem hiding this comment.
Important
Two status-bookkeeping gaps keep the new paused state from sticking: the ACP dispatch watchdog still treats paused as unfinished, and a stop that follows a pause can be overwritten by a late paused.
Reviewed changes
- Bridge
Interruptpause plumbing — the handler interface now takes apauseflag derived frompause_turnvsstop_turn. - Pause-aware turn status in the ACP runner — a per-turn
pauseRequestedflag reportspausedon cooperative cancel, cancel-during-spawn, and the post-grace-kill path. - Collapsed tool-call header — the inline command/path summary is removed from
tool-fallback.tsx; it remains in the expanded body. paca-dopublishing steps — the branch name must carry the task key, and the closing step is gated on the PR URL existing.
⚠️ paused is not treated as settled by the ACP dispatch watchdog
The bridge now leaves an ACP conversation at paused when the user pauses a turn, but every dispatch also arms a detached watchdog whose FailIfNotTerminal only excludes finished/failed/stopped. At the agent's timeout (timeout_minutes, 30 by default) a paused conversation is flipped to failed with the "ACP turn timed out…" message, and a watchdog left over from an earlier turn can fail a conversation the user has since resumed while that turn is still running.
Technical details
# ACP watchdog clobbers "paused"
## Affected sites
- `services/agent-runner/internal/acpbridge/dispatch.go:86-90` — a fresh watchdog is armed on every dispatch with `cfg.TimeoutMinutes`; no handle is retained.
- `services/agent-runner/internal/acpbridge/dispatch.go:121-124` — sleeps the full timeout, then calls `FailIfNotTerminal`.
- `services/agent-runner/internal/repository/postgres/conversation_repository.go:88-93` — guard is `WHERE status NOT IN ('finished', 'failed', 'stopped')`, so both a `paused` row and a resumed `running` row are updated to `failed`.
- `services/agent-runner/internal/acpbridge/server.go:352` — the unconditional `UpdateStatus` means the reverse direction (a late `paused` overwriting `failed`/`stopped`) is unguarded too.
- `services/api/internal/service/agent/agent_service.go:1949-1961` — `PauseConversation` deliberately writes nothing, so `paused` only ever comes from the bridge and never protects the row.
## Required outcome
- A paused ACP conversation must survive the deadline of the watchdog armed by its own turn.
- A watchdog armed by an earlier turn must not fail a later resumed turn.
- The fix may live in the watchdog rather than the shared SQL: startup reconciliation only lists `running` rows (`conversation_repository.go:68-70`), so it is unaffected by how `paused` is treated.ℹ️ Stale comment still claims ACP conversations never reach paused
agent_service.go:2628 documents the terminal-resume branch with "an ACP conversation never reaches 'paused' at all", which this PR makes false. ACP resumes now go through the paused branch above it, which runs its own capacity check, so the comment points future readers at the wrong invariant.
Technical details
# Stale "ACP never pauses" invariant
## Affected sites
- `services/api/internal/service/agent/agent_service.go:2625-2634` — "an ACP conversation never reaches \"paused\" at all (see the doc comment above)".
- `services/api/internal/service/agent/agent_service.go:2579-2607` — the paused resume path ACP conversations now take.
- `services/agent-runner/internal/acpbridge/dispatch.go:158-163` — `isTerminalStatus`'s doc repeats the same premise, which is the root of the watchdog issue above.
## Required outcome
- Comments describe the new reality: an ACP pause ends the turn at `paused` and resumes through the paused branch.deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
… and update related tests feat(api): clarify branch naming convention in paca-do.agent.md for better task linking
There was a problem hiding this comment.
Important
The three inline concerns from the previous review are fixed in 147c7e6, but the ACP watchdog gap raised then is unchanged at head: a correctly reported paused conversation is flipped to failed at the dispatch timeout, and a watchdog left over from an earlier dispatch can fail a turn the user has since resumed.
Reviewed changes
- Cleared a pending pause on a later stop —
Interruptnow assignsstate.pauseRequested = pause, sostop_turnafterpause_turnno longer reportspausedover the API'sstoppedon the cooperative andcontext.Canceledunwinds. - Asserted the pause flag in the bridge test — the fake handler records the boolean and
TestStopAndPauseTurnDispatchToInterruptnow expects[false true]forstop_turnthenpause_turn. - Added the empty-prefix branch fallback —
paca-do.agent.mdnow specifiesfeat/12-fix-login-bugwhen a project has notask_id_prefix, matching the web form'ssuggestBranchName.
⚠️ paused still cannot survive the ACP dispatch watchdog
The bridge now leaves an ACP conversation at paused, but the per-dispatch watchdog's FailIfNotTerminal still treats only finished/failed/stopped as settled. At the agent timeout (30 minutes by default) the paused row becomes failed with the "ACP turn timed out…" message, and a watchdog armed by the first dispatch can fail the same conversation after the user has resumed it while that new turn is still running. This was raised in the previous review, and no changed line in 147c7e6 touches it.
Technical details
# ACP watchdog clobbers "paused"
## Affected sites
- `services/agent-runner/internal/acpbridge/dispatch.go:86-90` — a fresh watchdog is armed on every dispatch with `cfg.TimeoutMinutes`; no handle is retained.
- `services/agent-runner/internal/acpbridge/dispatch.go:121-124` — sleeps the full timeout, then calls `FailIfNotTerminal`.
- `services/agent-runner/internal/repository/postgres/conversation_repository.go:88-93` — the guard is `WHERE status NOT IN ('finished', 'failed', 'stopped')`, so both a `paused` row and a resumed `running` row are updated to `failed`.
- `services/agent-runner/internal/acpbridge/dispatch.go:158-163` — `isTerminalStatus`'s doc repeats the same premise.
- `services/api/internal/service/agent/agent_service.go:2625-2634` — the terminal-resume comment still says "an ACP conversation never reaches \"paused\" at all", which this PR makes false; ACP resumes now take the paused branch at 2579-2607.
## Required outcome
- A paused ACP conversation must survive the deadline of the watchdog armed by its own dispatch.
- A watchdog armed by an earlier dispatch must not fail a later resumed turn.
- Comments in `agent_service.go` describe the new reality.
## Suggested approach (optional)
- Cancel the prior watchdog on resume, or only fail a conversation whose status is still `running` and whose current turn was dispatched by this watchdog's own dispatch.
- Startup reconciliation only lists `running` rows (`conversation_repository.go:68-70`), so the fix does not need to change how `paused` is treated there.deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…tate and improve watchdog logic
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline. The watchdog gap raised in the previous review is fixed for a single replica; the new guard is process-local, so the unconditional guarantee in its comment does not extend to multi-replica deployments.
Reviewed changes
- Per-dispatch generation guard in the ACP watchdog —
DispatchTriggernow stores a monotonically increasing generation per conversation and each watchdog only fails the row while its own generation is still the latest, so a watchdog armed by an earlier turn no longer fails a turn the user resumed on the same replica. pausedexempted from the watchdog's fail path —FailIfNotTerminal's conditionalUPDATEnow leaves a paused conversation untouched at the timeout, matching the new non-terminalpausedsemantics; the startup reconciler's use of the same helper only ever passes itrunningrows, so it is unaffected.- Corrected the "ACP never pauses" comment — the terminal-resume branch in
agent_service.gonow describes ACP conversations as reachingpaused, instead of denying it.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…d add e2e test for pause_turn
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Scoped the watchdog generation guard to this process — the
dispatchGenfield comment now states it is in-memory and that a resume handled by another replica is not seen, which resolves the multi-replica overclaim without changing behavior. - Moved the generation store ahead of the publish —
DispatchTriggerrecords the generation beforeRegistry.DispatchandCompareAndDeletes it on the publish-error and offline paths, so an earlier watchdog is already stale by the time the newstart_turncan reach the bridge. - Added
TestACPPauseTurn— an end-to-end test over the real HTTP+WebSocket server drivespause_turnto a fake bridge daemon, asserts the row reachespaused, and pins both sides of the watchdog: a paused row survivesFailIfNotTerminalwhile a genuinely stuckrunningrow is still failed.
The e2e package compiles (go test -run '^$' ./test/e2e/...); the new test needs PACA_E2E=1 and Docker, so it was not executed in this environment.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…cluding pause and stop functionality
There was a problem hiding this comment.
ℹ️ No critical issues — three test-reliability suggestions, one inline and two here.
Reviewed changes
- Added an ACP conversation e2e feature and spec — a fake bridge daemon connects over the real
/agent-bridge/wsendpoint with a generated agent token, consumesstart_turn/pause_turn/stop_turn, and reportsturn_statusback. - Covered chat dispatch — starting a project chat with the ACP agent dispatches
start_turnand leaves the conversationrunning. - Covered the composer pause flow — pressing Stop generating dispatches
pause_turn, then a bridge-reportedpausedmoves the badge to Waiting for reply and hides the button. - Covered an API full stop — stopping through the API dispatches
stop_turnand leaves the conversationStopped.
ℹ️ The full-stop test cannot detect the overwrite regression it names
The title and feature scenario say the bridge unwinds the turn, but the fake bridge never sends a turn_status after stop_turn, so the 1.5 s wait has nothing to observe and the final assertion would pass even if the daemon regressed to reporting paused on a stop. Either retitle the test to what it checks (the API records stopped and dispatches stop_turn) and drop the inert wait, or cover the invariant where it lives: a runner_test.go case for the grace-period force-kill with Interrupt(conv, false) asserting no turn_status, plus a pause case (Interrupt(conv, true)) asserting paused. No runner test currently calls Interrupt with pause=true at all.
Technical details
# Full-stop e2e test cannot observe the daemon-side suppression it names
## Affected sites
- `apps/e2e/tests/projects/acp-agent-conversations.spec.ts:192-217` — `reportTurnStatus` is only called in the pause test (line 184); nothing sends a status after the stop.
- `apps/acp-bridge/internal/runner/runner.go:416-437` — the force-kill/transport-error branch reports `paused` only when `pauseRequested`; the stop case reports nothing.
- `apps/acp-bridge/internal/runner/runner.go:456-466` — `reportPausedIfRequested` is the invariant the scenario refers to.
- `apps/acp-bridge/internal/runner/runner_test.go:550-597, 606-667` — only the cooperative-cancel and session-setup stop paths are covered; no runner test passes `pause=true`.
- `apps/e2e/features/projects/acp-agent-conversations.feature:37-42` — the scenario bakes in "the bridge reports nothing".
## Required outcome
- The test name and assertions describe what the test actually exercises, and the daemon-side stop suppression (and pause reporting) on the grace-period branch is covered by a runner test.ℹ️ The fake bridge never refreshes presence
FakeBridge sends only hello and turn_status, but the server's bridge-presence key has a 45 s TTL that only a ping refreshes. On a slow run every later dispatch is dropped (Registry.Dispatch returns false without publishing) and the 20 s next(...) waits fail for a reason unrelated to the behavior under test. Add a ~20 s ping interval after hello_ack, matching the real daemon's heartbeatInterval, and clear it in close().
Technical details
# Fake bridge never refreshes presence
## Affected sites
- `apps/e2e/tests/projects/acp-agent-conversations.spec.ts:41-105` — `FakeBridge` sends only `hello` and `turn_status`.
- `services/agent-runner/internal/acpbridge/registry.go:36-40, 179` — `presenceTTL` is 45 s and `Register` sets it once.
- `services/agent-runner/internal/acpbridge/registry.go:294-301` — only `Registry.Heartbeat`, called from the bridge `ping` handler (`server.go:226-229`), extends it.
- `apps/acp-bridge/internal/bridge/bridge.go:22, 199-204` — the real daemon pings every 20 s.
## Required outcome
- The fake bridge keeps its presence alive for the duration of a test, as the real daemon does.… in ACP agent conversations
There was a problem hiding this comment.
✅ No new issues found.
The three test-reliability items from the previous review are addressed, and the new bridge tests exercise the pause path that was previously uncovered. go test ./... and go vet pass in apps/acp-bridge, including the new runner tests.
Reviewed changes
- Added bridge-level pause tests —
TestEndToEndPauseReportsPauseddrivesInterrupt(conv, true)through the cooperative-cancel path and asserts thepausedstatus, closing the gap where no runner test passedpause=true. - Covered the session-setup pause branch —
TestEndToEndPauseDuringSessionSetupReportsPausedpauses whilestate.clientis still nil and asserts thecontext.Canceledunwind still reportspaused. - Pinned stop-supersedes-pause —
TestInterruptStopSupersedesPauseasserts a laterstop_turnclears the pending pause so nopausedcan overwrite the API'sstopped. - Retitled the full-stop e2e scenario — the spec test now says what it observes, drops the inert 1.5 s wait, and gives the badge assertion a 15 s timeout for the ACP path's 5 s reconcile interval.
- Refreshed fake-bridge presence —
FakeBridgenow pings every 20 s afterhello_ackand clears the timer inclose(), matching the real daemon against the server's 45 s presence TTL.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
Upstream merge (PR Paca-AI#706) removed the root Dockerfile that the Render paca service builds from (dockerfilePath ./Dockerfile), so the Nov 5 build failed with 'open Dockerfile: no such file or directory'. Restored unchanged from 2126bf1; it still matches services/api/Dockerfile. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016c4MSiitnTE5NEF3spAq1T

Summary
Three fixes around ACP agents.
1. Stop button leaves the conversation "running" (acp-bridge)
The composer's stop button calls
pauseConversation. The API writes no status for a pause and expects the runner to report it, but the ACP bridge sentsession/canceland never sent aturn_status, so the conversation stayed "running" in the UI.Handler.Interruptnow takes apauseflag, set frompause_turnvsstop_turn.pauseRequested, reset at turn start) and reportspausedonce the turn unwinds: on a cooperative cancel, on a cancel while still spawning, and after the grace-period force-kill (which could previously surface asfailed).stoppedand a latepausedwould overwrite it.2. Collapsed tool calls are cluttered (web)
tool-fallback.tsxno longer shows the command or file path inline in the collapsed trigger. It appears only when the tool call is expanded, which already shows the full command or args and diff paths.3.
paca-doagent skill: wrong branch name and PR skipped (api)paca-do.agent.mdtold agents to usefeat/<task-number>-<desc>, without the task key. Paca links a branch and PR to a task by the key (e.g.PACA-12) in the branch or title, so those branches never linked.<type>/<TASK-KEY>-<slug>, e.g.feat/PACA-12-fix-login-bug, matching the web app's create-branch form.Testing
go vetandgo test ./...pass inapps/acp-bridgeandservices/api/internal/platform/bundledskills; existing tests updated for the newInterruptsignature.tsc -band biome pass for the web change.Risk
Low. The bridge change is limited to interrupt handling, the web change removes one inline element, and the skill change is prompt text (it applies to new conversations only).