fix(agents): persist user turn before attempt failures#86764
fix(agents): persist user turn before attempt failures#86764TurboTheTurtle wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 15, 2026, 10:01 PM ET / July 16, 2026, 02:01 UTC. Summary PR surface: Source +106, Tests +273. Total +379 across 4 files. Reproducibility: yes. at source level: current success-path persistence occurs after the attempt, so a thrown CLI or ACP attempt exits before the user row is written; the linked issue and branch tests exercise that boundary. I did not independently run the failing current-main scenario during this read-only review. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Preserve one canonical shared recorder that writes an accepted turn exactly once to the correct transcript before runtime invocation, then rebase cleanly and prove failed, successful, empty-reply, fallback, rebound, and internal-session cases on the resolved head. Do we have a high-confidence way to reproduce the issue? Yes at source level: current success-path persistence occurs after the attempt, so a thrown CLI or ACP attempt exits before the user row is written; the linked issue and branch tests exercise that boundary. I did not independently run the failing current-main scenario during this read-only review. Is this the best way to solve the issue? Yes in principle: a shared exactly-once recorder before runtime invocation is narrower and safer than duplicating failure-specific persistence or writing synthetic assistant errors. Merge should wait for owner acceptance of the durable timing and refreshed proof after conflict resolution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 154d53c4f6fc. Label changesLabel justifications:
Evidence reviewedPR surface: Source +106, Tests +273. Total +379 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper PR egg ✨ Hatched: ✨ glimmer Brave Proofling Hatch commandComment Hatchability rules:
Rarity: ✨ glimmer. What is this egg doing here?
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b98f590 to
762e7ad
Compare
762e7ad to
b4229c0
Compare
b4229c0 to
3f7c036
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
3f7c036 to
25c0d62
Compare
|
Rebased onto current The focused transcript and runner suites passed 612 tests before the final replay. Exact-head CI then exposed two current-main contract updates: one accumulator mock now returns Exact-head GitHub CI is green: 68 checks passed with no failures. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
25c0d62 to
4b60514
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Real behavior proof
Behavior addressed: Internal ACP/CLI session-effects turns now persist the accepted user message into the active internal attempt transcript before the external runner can fail, and later successful transcript persistence reuses that same internal file without duplicating the user row or leaking the internal prompt into the visible session transcript.
Real environment tested: Local OpenClaw runtime modules from
/Users/andy/openclaw/openclaw-86592on macOS, writing real temporary OpenClaw session JSONL files through the production transcript persistence helpers.Exact steps or command run after this patch:
node --import tsx - <<'EOF' ... EOFruntime smoke that importspersistUserTurnTranscriptandpersistAcpTurnTranscript, starts with a visible session transcript, routes the current internal turn throughsessionFileOverride, then appends the assistant reply withuserAlreadyPersisted: true.Evidence after fix:
{ "internalSessionFileEndsWith": "internal-agent-runs/run-proof.jsonl", "visibleSessionFileEndsWith": "visible-session.jsonl", "afterUserSessionFileIsInternal": true, "internalMessages": [ "user:sanitized internal user prompt", "assistant:sanitized internal assistant reply" ], "visibleMessages": [ "user:existing visible session prompt" ], "visibleContainsInternalPrompt": false, "internalUserMessageCount": 1 }I also ran the targeted ClawSweeper regression suites after this patch:
Exact-head GitHub CI on
4b60514d98: 68 checks passed with no failures. The final compatibility amendment updates test mock return metadata for current-main types and removes a redundant initializer; independent review found no behavioral change.Observed result after fix: The pre-run user message lands in
internal-agent-runs/run-proof.jsonl, the ACP assistant append uses the same internal transcript withuserAlreadyPersisted: true, the visible transcript retains only its original visible prompt, and the internal user message appears exactly once.What was not tested: I did not launch a live external Claude/Codex CLI subprocess or a live ACP backend; this was a local OpenClaw runtime transcript smoke using real session persistence code, supplemented by targeted regression tests.
Summary
Tests
node --import tsx - <<'EOF' ... EOFlocal OpenClaw runtime transcript smokenode scripts/run-vitest.mjs src/agents/command/attempt-execution.cli.test.ts src/commands/agent.test.ts src/agents/agent-command.live-model-switch.test.tsnode scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/followup-runner.test.tsFixes #86592
AI-assisted: Codex was used to rebase this PR, resolve current-main conflicts, run focused checks, and perform independent review.