Skip to content

feat(bridge): enhance Interrupt method to support pause functionality… - #706

Merged
pikann merged 6 commits into
masterfrom
feature/enhance-acp-agent
Nov 5, 2026
Merged

pikann merged 6 commits into
masterfrom
feature/enhance-acp-agent

Conversation

@pikann

@pikann pikann commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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 sent session/cancel and never sent a turn_status, so the conversation stayed "running" in the UI.

  • Handler.Interrupt now takes a pause flag, set from pause_turn vs stop_turn.
  • The runner records it per turn (pauseRequested, reset at turn start) and reports paused once the turn unwinds: on a cooperative cancel, on a cancel while still spawning, and after the grace-period force-kill (which could previously surface as failed).
  • A full stop still reports nothing, since the API already wrote stopped and a late paused would overwrite it.

2. Collapsed tool calls are cluttered (web)

tool-fallback.tsx no 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-do agent skill: wrong branch name and PR skipped (api)

paca-do.agent.md told agents to use feat/<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.

  • Branch format is now exactly <type>/<TASK-KEY>-<slug>, e.g. feat/PACA-12-fix-login-bug, matching the web app's create-branch form.
  • Pushing and opening the PR is marked as part of "done", and the closing step gates on the PR URL existing.

Testing

  • go vet and go test ./... pass in apps/acp-bridge and services/api/internal/platform/bundledskills; existing tests updated for the new Interrupt signature.
  • tsc -b and biome pass for the web change.
  • Not verified: no new test for the pause/stop status split, and nothing run against a real ACP agent or in a browser.

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).

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Interrupt pause plumbing — the handler interface now takes a pause flag derived from pause_turn vs stop_turn.
  • Pause-aware turn status in the ACP runner — a per-turn pauseRequested flag reports paused on 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-do publishing 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — Interrupt now assigns state.pauseRequested = pause, so stop_turn after pause_turn no longer reports paused over the API's stopped on the cooperative and context.Canceled unwinds.
  • Asserted the pause flag in the bridge test — the fake handler records the boolean and TestStopAndPauseTurnDispatchToInterrupt now expects [false true] for stop_turn then pause_turn.
  • Added the empty-prefix branch fallback — paca-do.agent.md now specifies feat/12-fix-login-bug when a project has no task_id_prefix, matching the web form's suggestBranchName.

⚠️ 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.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 — DispatchTrigger now 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.
  • paused exempted from the watchdog's fail path — FailIfNotTerminal's conditional UPDATE now leaves a paused conversation untouched at the timeout, matching the new non-terminal paused semantics; the startup reconciler's use of the same helper only ever passes it running rows, so it is unaffected.
  • Corrected the "ACP never pauses" comment — the terminal-resume branch in agent_service.go now describes ACP conversations as reaching paused, instead of denying it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Scoped the watchdog generation guard to this process — the dispatchGen field 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 — DispatchTrigger records the generation before Registry.Dispatch and CompareAndDeletes it on the publish-error and offline paths, so an earlier watchdog is already stale by the time the new start_turn can reach the bridge.
  • Added TestACPPauseTurn — an end-to-end test over the real HTTP+WebSocket server drives pause_turn to a fake bridge daemon, asserts the row reaches paused, and pins both sides of the watchdog: a paused row survives FailIfNotTerminal while a genuinely stuck running row 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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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/ws endpoint with a generated agent token, consumes start_turn/pause_turn/stop_turn, and reports turn_status back.
  • Covered chat dispatch — starting a project chat with the ACP agent dispatches start_turn and leaves the conversation running.
  • Covered the composer pause flow — pressing Stop generating dispatches pause_turn, then a bridge-reported paused moves the badge to Waiting for reply and hides the button.
  • Covered an API full stop — stopping through the API dispatches stop_turn and leaves the conversation Stopped.

ℹ️ 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 — TestEndToEndPauseReportsPaused drives Interrupt(conv, true) through the cooperative-cancel path and asserts the paused status, closing the gap where no runner test passed pause=true.
  • Covered the session-setup pause branch — TestEndToEndPauseDuringSessionSetupReportsPaused pauses while state.client is still nil and asserts the context.Canceled unwind still reports paused.
  • Pinned stop-supersedes-pause — TestInterruptStopSupersedesPause asserts a later stop_turn clears the pending pause so no paused can overwrite the API's stopped.
  • 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 — FakeBridge now pings every 20 s after hello_ack and clears the timer in close(), matching the real daemon against the server's 45 s presence TTL.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit bcf1e68 into master Nov 5, 2026
15 checks passed
@pikann
pikann deleted the feature/enhance-acp-agent branch November 5, 2026 10:33
DigitalVertise pushed a commit to DigitalVertise/paca that referenced this pull request Nov 6, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant