fix(agents): persist user turn before attempt failures#86764
fix(agents): persist user turn before attempt failures#86764TurboTheTurtle wants to merge 4 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 7, 2026, 11:02 PM ET / 03:02 UTC. Summary PR surface: Source +121, Tests +460. Total +581 across 5 files. Reproducibility: yes. Source inspection shows current main persists CLI/ACP user rows from post-attempt transcript paths, so an exception before those paths leaves the accepted prompt unwritten; I did not execute the repro because this review was read-only. Review metrics: 1 noteworthy metric.
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
Security Review detailsBest possible solution: Land the narrow transcript-persistence fix after final merge-ref validation confirms CLI, ACP, internal session-effects, fallback retry, and hook/redaction behavior still match the intended transcript contract. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main persists CLI/ACP user rows from post-attempt transcript paths, so an exception before those paths leaves the accepted prompt unwritten; I did not execute the repro because this review was read-only. Is this the best way to solve the issue? Yes. The PR uses the existing approved user-turn recorder for CLI after before_agent_run, adds the same pre-run persistence for ACP, and uses userAlreadyPersisted/sessionFileOverride to avoid duplicate or visible/internal transcript drift. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 4780546c124d. Label changesLabel justifications:
Evidence reviewedPR surface: Source +121, Tests +460. Total +581 across 5 files. View PR surface stats
Acceptance criteria:
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
|
|
@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.
c37df1b to
6574b73
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b98f590 to
762e7ad
Compare
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:
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