Skip to content

fix: retain CLI conversations when child completions arrive - #164378

Merged
steipete merged 1 commit into
mainfrom
codex/cli-announce-policy
Oct 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cli-announce-policy

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes CLI-backed parent sessions losing their native conversation when a child-completion update arrives, which can prevent the expected completion reply from reaching the transcript.

User Impact

Child-completion turns retain the parent conversation and receive delivery instructions for the current turn. Existing sessions using the published implicit automatic-reply policy keep continuity after updating; their next completed turn records the current policy without operator action.

Why This Change Was Made

Ordinary direct-agent calls and synthetic completion calls now derive reusable reply policy from the same owner. Turn-specific delivery instructions remain outside the stable system prompt and stored user message. Binding admission recognizes only the three verified equivalent default-policy representations; authentication, workspace, MCP compatibility, and nondefault policy changes retain their existing checks.

Evidence

The original Docker CLI failure is recorded in Full Release Validation child 37119616846: the initial barrier, parent reply, and child delivery passed, then the completion turn reset for message-policy and failed the third transcript wait.

The real command-to-CLI preparation regressions failed before the fix for new, existing, and published default-policy sessions. The effective-delivery regression also failed before current-turn guidance was added. Focused proof preserves native session identity, transcript bytes, private plugin context, unavailable-tool guidance, and strict auth/workspace/MCP checks.

All 174 affected tests passed. The standalone regression command pnpm test src/agents/cli-runner/prepare.command-continuity.test.ts --maxWorkers=1 passed five cases in 88.18 seconds, including compiler and fixture setup (25.319 seconds of case execution). Full required changed checks passed, including formatting, types, lint, size limits, export and import-cycle guards. Final isolated review found no actionable P0–P2 findings. Live-provider behavior remains unqualified. One approved standard Testbox attempt remained queued without a runner or Actions URL beyond its ten-minute admission window and was released before any remote command or provider call; the live Docker lane did not run.

CI timing evidence from completed run 37133560587, on the reviewed head:

Changed test file Runtime Passed CI test-wrapper time
src/agents/cli-runner/prepare.command-continuity.test.ts Node 5 19.47s
src/agents/cli-runner/prepare.durable-context.test.ts Node 7 42.49s
src/agents/cli-runner/prepare.test.ts Node 122 61.09s
src/agents/cli-session.test.ts Bun 34 7.66s

These are the executed per-file test-wrapper timings, including their preparation overhead. The new continuity suite ran in checks-node-changed-3; the other three files ran in checks-node-changed-4. The live Docker lane remains unrun.

Prepare stable reply-policy binding facts for ordinary direct-agent calls and synthetic completions. Preserve published default-policy sessions and provide effective delivery guidance as private current-turn context without changing canonical user prompts.
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 3, 2026 15:31
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 11:38 AM ET / 15:38 UTC.

ClawSweeper review

What this changes

The PR preserves CLI-backed conversations across child-completion turns by sharing stable reply-policy facts, recognizing equivalent published defaults, and supplying delivery guidance separately from stored user messages.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix: current main still treats ordinary-call and completion-call reply fingerprints differently. No actionable introduced defect was found; related announcement-history work addresses an additional, distinct continuity problem.

Priority: P1
Reviewed head: 57dd907458c0e35d9e3c30292f1585984dbd5901

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused continuity repair with meaningful compatibility regressions and no supported blocking defect; live-provider coverage is explicitly unqualified.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Command-to-CLI preparation regressions cover the changed owners, but no after-fix live CLI recovery is claimed. Published fingerprint production, narrow normalization, and unchanged settlement verify existing-state compatibility without a new stored format.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Command-to-CLI preparation regressions cover the changed owners, but no after-fix live CLI recovery is claimed. Published fingerprint production, narrow normalization, and unchanged settlement verify existing-state compatibility without a new stored format.
Evidence reviewed 8 items Pinned introduced changes: Reviewed the merge-base-to-head delta at the supplied original head. The changes concern CLI preparation, native conversation compatibility, shared reply policy, focused regressions, and CLI-backend documentation.
Still necessary on current main: Fetched main still seeds CLI binding facts only for existing synthetic turns, while its session reuse owner compares default-policy fingerprints literally. The ordinary-call seeding and equivalent-default normalization remain absent.
Published default encodings verified: The latest-release preparation source computes no fingerprint when both policy arguments are absent, and hashes only requireExplicitMessageTarget when that argument alone is false. These match the two legacy representations admitted by the patch. The published command path seeds binding facts only for existing synthetic turns.
Findings None None.
Security None None.

How this fits together

OpenClaw's CLI runner translates agent requests into turns for an external AI CLI. It checks saved conversation bindings before resuming them and prepares prompts and tool context for the selected backend.

flowchart TD
 A[Direct agent request] --> C[Stable session reply policy]
 B[Child completion update] --> C
 C --> D[Conversation compatibility checks]
 D --> E[Resume or start CLI conversation]
 B --> F[Current turn delivery guidance]
 F --> E
 E --> G[Reply and transcript settlement]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +69, Tests +320, Docs +9. Total +398 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 149 80 +69
Tests 4 419 99 +320
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 577 179 +398

Review metrics

Metric Value Why it matters
Production versus regression growth production +69 net lines; tests +320 net lines Production growth supports current-turn guidance and published-default compatibility; regression growth covers command composition and upgrade cases.

Technical review

Best possible solution:

Retain native CLI continuity for equivalent session policies while keeping per-turn guidance separate and preserving account, workspace, and tool compatibility boundaries.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the fingerprint mismatch between ordinary direct calls and subsequent synthetic completion calls; the PR supplies focused before-fix regressions. This review did not execute a runtime reproduction.

Is this the best way to solve the issue?

Yes, reusing the existing reply-policy owner and narrowly admitting equivalent published defaults repairs the mismatch without dropping MCP or authentication compatibility checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a163d9b3db61.

Labels

Label changes:

  • add P1: The reported release-validation failure loses a CLI parent conversation during child completion and prevents the expected completion reply.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Command-to-CLI preparation regressions cover the changed owners, but no after-fix live CLI recovery is claimed. Published fingerprint production, narrow normalization, and unchanged settlement verify existing-state compatibility without a new stored format.

Label justifications:

  • P1: The reported release-validation failure loses a CLI parent conversation during child completion and prevents the expected completion reply.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Command-to-CLI preparation regressions cover the changed owners, but no after-fix live CLI recovery is claimed. Published fingerprint production, narrow normalization, and unchanged settlement verify existing-state compatibility without a new stored format.

Evidence

What I checked:

  • Pinned introduced changes: Reviewed the merge-base-to-head delta at the supplied original head. The changes concern CLI preparation, native conversation compatibility, shared reply policy, focused regressions, and CLI-backend documentation. (src/agents/command/prepare.ts:311, 57dd907458c0)
  • Still necessary on current main: Fetched main still seeds CLI binding facts only for existing synthetic turns, while its session reuse owner compares default-policy fingerprints literally. The ordinary-call seeding and equivalent-default normalization remain absent. (src/agents/command/prepare.ts:311, a163d9b3db61)
  • Published default encodings verified: The latest-release preparation source computes no fingerprint when both policy arguments are absent, and hashes only requireExplicitMessageTarget when that argument alone is false. These match the two legacy representations admitted by the patch. The published command path seeds binding facts only for existing synthetic turns. (src/agents/cli-runner/prepare.ts:703, fc23bc864e45)
  • Narrow compatibility repair: Normalization equates only absent, explicit-false legacy, and current automatic-default fingerprints. Auth-profile, auth-epoch, workspace, and MCP checks remain separate; nondefault fingerprints still invalidate reuse. Existing settlement writes the current fingerprint on the retained binding without introducing a stored field or schema. (src/agents/cli-session.ts:216, 57dd907458c0)
  • Prompt and transcript separation: The runner derives delivery guidance from the effective current-turn mode and actual message-tool availability. Plugin execution receives private prompt context; raw execution receives composed turn text. The original user prompt remains the transcript input, and authority checks still run after asynchronous preparation. (src/agents/cli-runner/prepare.ts:1705, 57dd907458c0)
  • Regression coverage and proof qualification: The new command-to-preparation cases exercise fresh, existing, and both published-default session shapes. Additional cases preserve transcript text and reject nondefault policy and auth/workspace/MCP changes. The captured PR body reports 174 passing affected tests and before-fix failures, but explicitly states that the live Docker lane did not run. No tests were executed during this read-only review. (src/agents/cli-runner/prepare.command-continuity.test.ts:63, 57dd907458c0)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 4ab3822 into main Oct 3, 2026
199 of 201 checks passed
@steipete
steipete deleted the codex/cli-announce-policy branch October 3, 2026 16:44
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…#164378)

Prepare stable reply-policy binding facts for ordinary direct-agent calls and synthetic completions. Preserve published default-policy sessions and provide effective delivery guidance as private current-turn context without changing canonical user prompts.
bresleveloper pushed a commit to bresleveloper/openclaw-dev-mode that referenced this pull request Oct 17, 2026
Report by the VPS agent, 2026-10-12 (dev-mode/claude-sub/
bug-cron-session-target-cli-amnesia.md, phone number redacted): a cron job
with sessionTarget "session:<chat key>" and the default announce delivery
runs in the chat's session, but upstream hands the run's delivery plan
(requireExplicitMessageTarget: true) to the CLI runner as the session's
binding facts. messageToolPolicyHash then differs from the chat's,
resolveCliSessionReuse resets the Claude CLI session (reason=message-policy)
and settlement stores the cron hash on the chat row, so the next chat turn
resets again: the chat agent forgets everything twice per run.

Fork-owned src/cron/isolated-agent/fork-cron-cli-binding-facts.ts: a run
that reuses a persistent non-cron session binds with upstream's
resolveSessionStableReplyMode and no requireExplicitMessageTarget, the rule
upstream already applies to heartbeats (openclaw#121485) and agent-command turns
(openclaw#164378). The run's delivery rules still apply per turn. Isolated/current
runs and cron-keyed sessions keep the per-run facts. One hook in
run-executor.ts wraps upstream's three fact lines. Not dev-mode gated.
Still open upstream on main 95a27d0 (2026-10-16).

Fork test fork-cron-cli-binding-facts.test.ts (4/4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant