feat(acp): auto-resume runtime on sendPrompt when inactive (#4695) - #4696
Conversation
When sendPrompt() finds no active runtime for a session, automatically attempts to resume the ACP session via session/resume before giving up. This unblocks long iterative sessions where CC goes idle between prompts. Previously, sending a message to an idle session silently failed with 'no_acp_runtime' β the message was accepted but never delivered. Changes: - sendPrompt() now accepts optional cwd parameter for auto-resume - New autoResumeRuntime() helper in backend/prompts.ts - Route handlers pass session.workDir as cwd - 4 new tests covering: auto-resume success, no agent session, no cwd, and regression (active session not resumed) Fixes #4695
There was a problem hiding this comment.
ποΈ Argus Review β LGTM (pending CI)
Review completed: Clean diff, well-structured auto-resume logic.
Gates 1-9:
β
Review completed β 356 additions, 5 files, focused on the fix
β
No conflicts β mergeable: true
β³ CI β tests/lint/security all green. feat-minor-bump-gate failing (advisory). helm-smoke still running (slow).
β
No regressions β existing sendPrompt path unchanged when runtime is active
β
Unit tests β 4 new tests covering: auto-resume success, no acpAgentSessionId, no cwd, active session (no resume attempt)
β
E2E/UAT β verified via vitest (4/4 new + 23/23 regression pass)
β
Documented β PR body is thorough with acceptance criteria
β
Security clean β no secrets, resume uses existing ACP protocol methods
β
Targets develop β confirmed
Code quality notes:
autoResumeRuntime()in prompts.ts is clean β tries resume, returns null on failure, caller falls through to existing error path. Good defensive design.sendPrompt()signature change (optionalcwdparam) is backward-compatible β existing callers unaffected.- Route files pass
session.workDirβ correct, matches the existing pattern. - Test coverage is thorough for the happy path and all 3 failure modes.
backend.tsat 499 lines β right at the gate limit. Future PRs touching this file will need extraction.
Verdict: LGTM. Will merge once helm-smoke completes.
Summary
Fixes #4695 β Auto-resume del runtime ACP su sendPrompt quando non attivo.
Problem
When CC goes idle after completing a turn, the ACP runtime is removed from the active runtimes map. The next
sendPrompt()call finds no runtime and silently returns{delivered: false, error: 'no_acp_runtime'}. The user seesok: truefrom the API but the message is never delivered to CC.This blocks all iterative session workflows β every prompt after the first one fails.
Fix
When
sendPrompt()finds no active runtime:acpAgentSessionIdstartResumeRuntime()(spawn fresh CC process + session/resume){delivered: true}All via existing ACP protocol methods β no new extensions.
Changes
src/services/acp/backend.ts:sendPrompt()accepts optionalcwdparam, callsautoResumeRuntime()when no runtimesrc/services/acp/backend/prompts.ts: NewautoResumeRuntime()helpersrc/routes/session-actions.ts: Passsession.workDirtosendPrompt()src/routes/sessions.ts: Passsession.workDirtosendPrompt()src/__tests__/acp-sendprompt-auto-resume-4695.test.ts: 4 new testsTests
npx vitest run src/__tests__/acp-sendprompt-auto-resume-4695.test.ts: 4/4 passnpx vitest run src/__tests__/acp-backend.test.ts: 23/23 pass (regression)npm run gate:arch: pass (backend.ts 499 lines)npx tsc --noEmit: passAcceptance Criteria
ag senda sessione idle β resume + consegnadelivered: truesu successoFixes #4695