fix(agents): persist CLI user turns before attempts#86624
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 25, 2026, 8:54 PM ET / 00:54 UTC. Summary PR surface: Source +59, Tests +143. Total +202 across 11 files. Reproducibility: yes. source-reproducible: current main only writes the CLI user prompt in post-run persistence, so a thrown CLI backend exits before the user line is appended. The PR also supplies live Telegram after-fix proof rather than only mock tests. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the CLI transcript durability fix once maintainers accept the session-state ordering, and keep or create a narrower ACP follow-up if the linked issue is broader than this patch. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main only writes the CLI user prompt in post-run persistence, so a thrown CLI backend exits before the user line is appended. The PR also supplies live Telegram after-fix proof rather than only mock tests. Is this the best way to solve the issue? Yes for the CLI path: persisting after before_agent_run approval and before backend/llm_input failure is the narrow durable-transcript fix, with post-run and fallback duplicate suppression. The ACP closure scope is still a maintainer decision, not a code defect in this CLI patch. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against c9364f03dcbb. Label changesLabel justifications:
Evidence reviewedPR surface: Source +59, Tests +143. Total +202 across 11 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
|
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Brave Proofling Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
|
Closing this as superseded by current main. The CLI user-turn durability path is now covered by the newer user-turn transcript recorder flow, including early approved-turn persistence and fallback duplicate-suppression coverage. Keeping this PR open would mostly mean dropping the old patch during conflict resolution rather than fixing a remaining behavior gap. |

Summary
before_agent_runhooks pass and before the backend attempt or nonblockingllm_inputnotification can fail.Fixes #86592
Verification
pnpm test src/agents/cli-runner.reliability.test.ts src/agents/command/attempt-execution.cli.test.ts src/commands/agent.test.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/followup-runner.test.ts -- --reporter=verbosepnpm format:check src/agents/agent-command.ts src/agents/cli-runner.reliability.test.ts src/agents/cli-runner.ts src/agents/cli-runner/types.ts src/agents/command/attempt-execution.cli.test.ts src/agents/command/attempt-execution.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/followup-runner.test.ts src/auto-reply/reply/followup-runner.ts src/commands/agent.test.tspnpm tsgo:corepnpm tsgo:core:testnode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/agent-command.ts src/agents/cli-runner.reliability.test.ts src/agents/cli-runner.ts src/agents/cli-runner/types.ts src/agents/command/attempt-execution.cli.test.ts src/agents/command/attempt-execution.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/followup-runner.test.ts src/auto-reply/reply/followup-runner.ts src/commands/agent.test.tsgit diff --checkReal behavior proof
Behavior addressed: accepted Telegram topic user turns are persisted before the agent attempt, so a follow-up in the same topic/session can read the prior user turn instead of losing it when the first candidate owns persistence.
Real environment tested: local OpenClaw source checkout at
052bde7ac426524808a04ccf97a2aebf6a0cf2e1; gateway running locally; Telegram bot channel in polling mode; Telegram supergroup topic; default model route resolved toopenai/gpt-5.5.Exact steps or command run after this patch:
@Tfungbot Reply exactly: group topic route worksin a Telegram topic.@Tfungbot Reply exactly: topic first turn persistedin the same topic.@Tfungbot What did I ask you to reply exactly?in the same topic.pnpm openclaw models status.pnpm openclaw channels status --channel telegram --probe --json.pnpm openclaw logs --limit 160 --plain.Evidence after fix:
pnpm openclaw models statusresolved the default model route toopenai/gpt-5.5with no missing provider in use.pnpm openclaw channels status --channel telegram --probe --jsonreported Telegram configured, running, connected, polling mode, andprobe.ok: true.pnpm openclaw logs --limit 160 --plain:Observed result after fix: the bot replied inside the same Telegram topic, and the follow-up answer returned
topic first turn persisted, proving the previous accepted user turn was available in the live topic session.What was not tested: cross-account Telegram routing and non-Telegram channels were not re-run locally. The focused live proof covers the Telegram topic/session path touched by this fix; regression tests cover CLI/direct agent, queued follow-up, fallback suppression, and session JSONL persistence.