Skip to content

fix(acp): keep completed run-mode sessions resumable - #107366

Closed
henkterharmsel wants to merge 3 commits into
openclaw:mainfrom
henkterharmsel:agent/acp-oneshot-followup-resume
Closed

henkterharmsel wants to merge 3 commits into
openclaw:mainfrom
henkterharmsel:agent/acp-oneshot-followup-resume

Conversation

@henkterharmsel

@henkterharmsel henkterharmsel commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #106696.

What Problem This Solves

Fixes lost conversation context when a parent sends a follow-up to a completed ACP mode="run" child.

User Impact

Parents can continue a completed Claude or Codex one-shot using the same child key, confirmed conversation identity, and working directory. Unsupported, unconfirmed, legacy metadata-loss, and confirmed missing-target cases fail explicitly instead of silently starting a new conversation. Workers are still released after completion.

Ordinary parent-owned completed-child follow-ups return asynchronous accepted, including with a positive send timeout, and use the current session-follow-up completion owner. Explicit caller-owned and scoped-grant completion retain their existing inline behavior. Persistent sessions retain agent-ID-first resume selection.

Why This Change Was Made

Resume eligibility is recorded only when the backend advertises support and a completed turn confirms usable identity. Follow-ups stay on that backend. Current operation admission, requester authority, generation fencing, prompt restoration, and MCP ownership remain in place; ambiguous errors preserve retryable identity.

This refresh ports the fix to the current completion owners instead of restoring the retired task registry. Dispatch and completion now consume the same prepared requester/target facts in the existing follow-up module. A review regression also fixes a speculative bridge lookup rejecting valid listed sessions when that optional bridge is absent; genuine Gateway errors still propagate.

Maintainer decision still needed: completed one-shot identity retention/deletion, the optional backend capability contract, and asynchronous parent completion. This patch does not reconstruct previously deleted legacy state or promise that an older version preserves the new resume flags. No merge approval is presumed.

Evidence

Current head 7913b4932edd1839318513d6feba4a09a41ad893, based on bf8da001d61c25e8c4dcc1eeaa6ea88a62ef4f97, uses upstream ACPX 0.19.4 without a dependency override.

Current-Head Fixture Corrections

CI at 2450afa identified two test-only issues: the resume store fixture omitted required cfg and storePath fields, and five closed mocks lacked the current isolation contract. This head supplies the fixture fields, removes the unnecessary command-list mock, and documents the four intentional host/config/delivery/custody boundaries. No production code, assertions, or baselines changed.

The record-replacement suite passed 6/6 tests (38.10 seconds runner wall time), and the bridge suite passed 4/4 with real command discovery (12.52 seconds runner wall time). Formatting, syntax-only lint, and diff checks pass. The agent follow-up file changed only comments; its preceding 47-test grouped validation remains applicable to its unchanged executable content. The native TypeScript-based ratchet and typecheck are left to fresh CI, not claimed locally passing.

Cancellation Correction (2450afa)

CI at preceding head fda8887b7c1c957dee0e36d1aad7e2c396f0aaef exposed a real regression in two unchanged owner/lifecycle-replacement tests: cancellation lost its durable terminal signal while awaiting identity reconciliation. The exact CI base's runner and test were compared; this was not classified as inherited.

That commit changes only manager.turn-runner.ts: pre-publication reconciliation is limited to completed, non-aborted one-shots. Persistent and cancelled turns retain upstream publication-before-final-reconciliation ordering, including its authority checks. Strict one-shot identity persistence remains intact.

The two cancellation-replacement cases and four one-shot completion/readiness cases passed: 6/6 tests in two files, 130.61 seconds command wall time, 36.87 seconds project duration. Syntax-only lint and diff checks pass. Independent narrow review found no actionable P0-P2 findings. An earlier worker-preparation attempt stopped before tests and is not counted as passing evidence.

Broader Refresh Validation (fda8887)

  • The initial selected 15-file run passed 154 tests. Four copied fixtures failed because the current state-event reader is asynchronous; those call sites now await the existing API, with no runtime workaround.
  • That refresh's affected rerun passed 47/47 tests across five files: one-shot completion, public ACP follow-up routing, native child coordination, native follow-up authority, and bridge resume/reset. This rerun overlaps the initial run; the counts are not additive.
  • The canonical-session bridge regression was observed failing with No session found: acp-bridge:agent:main:work, then passed after making only the speculative lookup allow a missing result. Explicit routing and reset siblings also pass.
  • Earlier unchanged adapter coverage includes recreated processes, preserved context/cwd and MCP ownership, and refusal to silently start fresh when a confirmed target is missing.
  • Formatting, syntax-only lint, and git diff --check pass. No unit-test assertions, lint limits, or baselines were weakened.

Commands used the repository runner: pnpm test <selected-files> --maxWorkers=1. The final five-file command took 1333.86 seconds, including 340 seconds preparing worker artifacts. Its three project durations were 889.54, 23.64, and 31.32 seconds. These are grouped local measurements, not individual-file or CI timings. Current-head CI timings remain pending. Persistence, requester retirement, and adapter-process boundaries use the real owners; pure predicate mocks would not cover those contracts.

The official full-candidate autoreview reported no actionable P0-P2 findings. An additional independent review found the optional-bridge defect above; the regression and correction address it. A fresh narrow review of the subsequent existing-owner extraction and bridge correction found no further P0-P2 findings. These are static reviews, not provider or delivery proof.

Release-State Compatibility (fda8887)

An isolated source-owner probe used exact v2026.10.3 (59cb44796b0f1f0daa0e37af8b1495abb45d9bc1), real SQLite persistence/migration owners, synthetic session state, and a synthetic ACP backend. It established:

  • A byte-verified closed release snapshot at shared/agent schemas 20/24, with legacy IDs, working directory, parent/lifecycle identity, and transcript markers.
  • Offline migration to 24/27; persistent resume retained agent-ID-first selection. An unconfirmed legacy one-shot did not auto-resume. Once a synthetic turn confirmed its new ACP identity, the next turn reused that identity and the same child key/cwd, preserving state on close.
  • Separate post-exit observation and fresh-process candidate reopen recovered the persisted flags/IDs and original transcript markers, with integrity checks.
  • The exact old release refused newer schemas without changing database bytes. Restoring the untouched release snapshot into a new directory recovered matching old session rows and transcripts at 20/24.
  • A schema-neutral additive-field roundtrip remained readable by the old release. Its normalizer dropped unknown resume flags and retained legacy agent-first selection; preservation after old-runtime rewriting is not claimed.

The observation, reopen, refusal, restore, additive-write, and additive-read phases each exited 0 without timeout and retained unchanged source fingerprints. Three earlier failures remain recorded: incorrect migration ownership in the harness; a 300-second proof-process timeout; and an overstrict observation guard rejecting a zero-byte WAL with retained SHM after behavior and shutdown assertions passed. The last failed outcome was not rewritten: a separate read-only observation completed it. Snapshot-copy checks stayed strict, and no sidecars or schema markers were deleted or rewritten to force a pass.

This is source-owner persistence evidence at the preceding refresh head, not installed-package updater or CLI backup-archive restore E2E proof. It did not use provider credentials, production state, Telegram, or real ACP subprocesses. The subsequent cancellation and test-only corrections do not change metadata formats or migration code; the full compatibility probe was not repeated for them.

Historical Provider Proof

The following real-provider proof belongs to previous head 8f2ce3799f8bbbb20cd197e94fa624a1a60660ca, not this refresh. On 2026-09-24, isolated Claude ACP 0.78.0 and Codex ACP 1.12.0 runs using ACPX 0.19.1 completed a nonce-bearing one-shot, shut down/recreated the adapter, and resumed with the original backend identity. Both recalled the nonce and working directory without repeating the nonce; tool events were zero. Source/dependency hashes stayed unchanged.

This was adapter-level continuity proof, not a full Gateway restart or Telegram delivery test. It must not be read as fresh provider validation of this candidate.

Remaining Gaps

Type-aware lint/typechecking and the repository-wide suite are not run locally under host constraints. No check limits or baselines were relaxed. New-head CI and maintainer contract acceptance remain required. Previous-head CI failures are not assumed fixed merely because the base changed.

AI-assisted implementation, review, and validation.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: acpx size: XL labels Jul 14, 2026
@henkterharmsel
henkterharmsel marked this pull request as ready for review July 14, 2026 10:18
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 2450afa2e5bd9f8361be2ada450637a715dbbc9c, but the PR head is now 7913b4932edd1839318513d6feba4a09a41ad893. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (35 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T12:34:25.867Z sha a6325224bf373cdb1c25330b731209616acf34e3 :: blocked before merge. :: [P2] Resolve the bridge key before applying the requested reset
  • reviewed 2026-09-20T12:47:48.915Z sha 25d0a689fb0872f25bac99e39c5249336aab9cfe :: blocked before merge. :: [P2] Resolve the bridge key before applying the requested reset
  • reviewed 2026-09-20T13:18:02.593Z sha 99a7014a0c86370d62963be40d359ef11f828586 :: blocked before merge. :: [P2] Resolve the bridge key before applying the requested reset
  • reviewed 2026-09-21T09:16:20.668Z sha 31d7619309a744cb63e19111cba1af3d38e101bf :: blocked before merge. :: [P3] Replace new wall-clock waits with deterministic synchronization
  • reviewed 2026-09-24T14:19:31.669Z sha cf12b92744ffd7955ba1992d641c99da908d5df4 :: blocked before merge. :: none
  • reviewed 2026-09-24T14:39:17.782Z sha 8f2ce3799f8bbbb20cd197e94fa624a1a60660ca :: blocked before merge. :: none
  • reviewed 2026-10-09T01:31:09.192Z sha 8f2ce3799f8bbbb20cd197e94fa624a1a60660ca :: blocked before merge. :: none
  • reviewed 2026-10-15T16:36:22.199Z sha 2450afa :: needs real behavior proof before merge. :: [P2] Keep non-resumable one-shot completion best effort | [P2] Remove the introduced adapter line-cap growth | [P2] Make the added mocks satisfy the export-preservation check

@henkterharmsel
henkterharmsel force-pushed the agent/acp-oneshot-followup-resume branch 2 times, most recently from b438552 to 40e6ec7 Compare July 14, 2026 21:13
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 15, 2026
@henkterharmsel
henkterharmsel force-pushed the agent/acp-oneshot-followup-resume branch 2 times, most recently from c1606f1 to c47d91b Compare July 16, 2026 14:32
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 16, 2026
@henkterharmsel
henkterharmsel force-pushed the agent/acp-oneshot-followup-resume branch from c47d91b to 6cba910 Compare July 27, 2026 16:23
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 27, 2026
@henkterharmsel
henkterharmsel force-pushed the agent/acp-oneshot-followup-resume branch 2 times, most recently from 80c54eb to 26049aa Compare July 27, 2026 18:42
@henkterharmsel
henkterharmsel force-pushed the agent/acp-oneshot-followup-resume branch from 99a7014 to 31d7619 Compare September 21, 2026 09:07
@henkterharmsel

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the actionable reset finding and refreshed the branch onto e1f5a26ddb7:

  • Resolve the recovered bridge key before applying metadata/default reset, then read the post-reset snapshot. Restart-plus-reset regressions failed before the correction and pass afterward; explicit routing remains authoritative.
  • Took the suggested compatibility option: persistent sessions retain agent-ID-first resume selection. Backend-ID-first selection is limited to eligible one-shots. Added stored-identity fixtures with missing capability flags, differing IDs, and a second backend. These are automated compatibility tests, not a claim of live third-party backend upgrade testing.
  • Fixed the stale ACP-shadow routing regression, test lint/type issues, unused export, and file-length growth without relaxing limits or removing coverage.
  • Added fresh exact-head Claude/Codex runtime-recreation proof and current validation results to the body. Full gateway validation is not claimed: the candidate hit the watchdog; clean upstream reproduced the initial failure sequence; the originally reported native-subagent case passes in isolation. Full build/type-aware checks remain for CI.

Maintainer acceptance is still needed for retaining confirmed completed-child identity, the optional resume capability contract, and asynchronous completed-one-shot follow-up delivery. The body documents the legacy rejection and compatibility boundaries; this update does not claim those decisions have been approved.

@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Sep 21, 2026
@henkterharmsel

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated this existing PR to cf12b92744ffd7955ba1992d641c99da908d5df4 on b9da50953aa.

  • Replaced the new 1 ms real timeout with explicit fake-clock advancement in the existing timer lane, preserving abort assertions. Replaced completion polling with owned deferred/completion promises.
  • Corrected the reconnect fixture's literal-default type error and updated maintenance/agent-command fixtures for current upstream APIs.
  • Preserved confirmed resume readiness across physical record replacement only for an explicit same-backend/protocol resume; new-handle identifiers and capability remain authoritative. Six regressions pass.
  • Added per-file test timing, command-wall samples, and explicit performance/validation limitations to the PR body. 275 distinct focused tests passed across 17 files, plus a 10-test final rerun. Changed-file syntax lint and existing line caps pass; full typecheck remains for CI.
  • Fresh exact-head live proof passed with ACPX 0.19.1, Claude ACP 0.78.0, and Codex ACP 1.12.0 after runtime recreation: same backend identity/context/cwd, zero tool events, and all 2,931 captured hashes unchanged. No real Telegram sends.
  • The full review's initialization-recovery P2 was rejected using its enclosing if (persistedResumeSessionId) guard. A final focused Codex review with complete function context found no actionable P0-P2 issue.

The body supersedes the old-head proof and test summaries. Historical unrelated/unattributed CI failures are not claimed fixed, and new-head CI remains required. There were no unresolved inline review threads at inspection.

Maintainer acceptance is still required for retention/deletion and upgrade/rollback expectations, the optional resume capability contract, and asynchronous completed-child follow-up delivery. Those decisions are not self-approved by this update.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@henkterharmsel

Copy link
Copy Markdown
Contributor Author

CI follow-up at 8f2ce3799f8bbbb20cd197e94fa624a1a60660ca:

  • Confirmed the exact check-test-types failure at the preceding head: TS2345 in extensions/acpx/src/runtime-resume.test.ts, where two-element table rows conflicted with a required three-argument callback. This was our fixture issue.
  • Changed only that test file: all 12 reconnect rows now explicitly provide the third value. AST comparison confirmed unchanged case values; no runtime code or assertions changed.
  • Targeted 43 tests passed: 0.276 s test/hook time, 25.71 s command wall time, one worker/two-core affinity. Formatting, syntax-only lint, and diff checks passed. No broad test run or whole review was repeated; prior runtime review and 275-test evidence remain identified separately in the body.
  • Fresh exact-head live proof at 2026-09-24 14:27 UTC passed for Claude ACP 0.78.0 and Codex ACP 1.12.0 with ACPX 0.19.1: preserved backend identity, context and working directory after adapter recreation; zero tool events; source unchanged and checkout clean. Isolated state, no credential refresh, no Telegram sends.
  • No local typecheck was run under host constraints. Fresh CI typecheck and maintainer contract acceptance remain required; unrelated CI failures are not claimed fixed.

The PR body now carries the current head, fresh live proof, measured timings, prior rejected-review rationale, and remaining gaps.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@henkterharmsel

Copy link
Copy Markdown
Contributor Author

Refreshed this PR onto the current completion owners, with the body separating current-head checks from preceding-head and historical provider evidence.

Current head: 2450afa2e5bd9f8361be2ada450637a715dbbc9c.

  • CI exposed a real cancellation-ordering regression at the preceding refresh head. Early identity reconciliation now applies only to completed, non-aborted one-shots; persistent/cancelled turns retain upstream terminal-publication ordering and authority checks.
  • All six focused cancellation and one-shot regressions pass on the current head. Syntax-only lint, diff checks, and independent narrow review are complete. The preceding refresh's 47-test rerun and scoped release-state compatibility evidence remain explicitly identified in the body.
  • The compatibility probe covers persisted identity/history, old-reader schema refusal, and restoration of its untouched synthetic release snapshot. It is not installed-updater, provider, or Telegram delivery proof; failed exploratory attempts remain recorded.

Current-head CI and maintainer acceptance of the lifecycle/capability contract are still required. No merge approval is presumed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @henkterharmsel for investigating this and proposing the fix. We reproduced the completed-run continuity problem on main and merged a focused replacement in #189273, preserving your coauthor credit. It retains recorded ACPX conversations and returns asynchronous follow-up results through the existing completion owner. The broader unsupported-harness and legacy-metadata cases remain tracked in #106696.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: acpx P2 Normal backlog priority with limited blast radius. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP run-mode one-shots do not resume completed backend sessions

4 participants