Skip to content

fix: preserve Code Mode recovery after wrapped tool output - #176407

Merged
roboclaw-bot merged 5 commits into
mainfrom
openclaw/pi-typed-recovery-facts
Oct 18, 2026
Merged

roboclaw-bot merged 5 commits into
mainfrom
openclaw/pi-typed-recovery-facts

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes restart recovery losing a safe Code Mode checkpoint when tool-result hooks wrap or rewrite its displayed output.

User Impact

Safe interrupted Code Mode work can resume after a restart without trusting rewritten display text. Unsafe or unfinished effects are not made replayable by forged output. Existing text-only transcripts keep their recovery behavior; this change adds no configuration requirement.

Why This Change Was Made

Record execution status and replay safety at the producer, carry them through existing private result provenance, and stamp the canonical transcript after serialization. Current checkpoints are authoritative, including explicit non-checkpoints; legacy text parsing remains only for older transcripts.

The shared pre-commit fix has since landed upstream. Conflict resolution keeps upstream's exact pnpm run invocation and both its compound-script test and this branch's real-hook success/failure and spaced-filename tests. The CI repair supplies the fixture's required optional: true metadata; it does not change production behavior.

Evidence

  • Wrapped-output regressions failed on the base; serializer forgery was reproduced before repair. Earlier targeted validation passed 336 tests across 11 files, including recovery, exec/wait, hooks, normalization, consumers, and prompt-prefix stability.
  • Real-model isolated cold restarts restored the safe wrapped checkpoint and kept the unfinished-effect count at exactly one. The safe case passed within a subsequently stopped two-case run; the separate unfinished-effect run exited successfully.
  • Diagnosed CI run 39162450158/job 117779080313: the new fixture omitted required PluginToolMeta.optional. Reproduced the exact type error locally, fixed it, and passed the affected agents-tools type graph plus all six integration cases. Normal commit hooks passed; old remote CI is not represented as green.
  • Verified npm latest was 2026.10.4 and installed that authentic release (383c124) into an isolated prefix. A real OpenAI turn through its native Gateway produced a legacy checkpoint; no transcript rows were handcrafted. Switching the same state to the candidate correctly required Doctor; candidate Doctor exited 0, then public history and automatic recovery resumed the real model with exec/wait and completed the requested marker.
  • All seven original decoded transcript-event payloads survived byte-for-byte; recovery appended two events. Legacy checkpoint, agent/tool settings, and synthetic workspace data survived. Public projection adds one derived usage.contextUsage field. Doctor updated its timestamp and disabled unavailable optional skills; the harness changed its loopback proxy port. Whole-config/public-JSON byte identity is not claimed.
  • Upgrade runtime was the reviewed dirty-feature build on base a830701 (built 2026-10-18T19:53:02.901Z); all five feature-production hashes remain unchanged. This is real state-upgrade/recovery proof, not candidate-package installer certification. Existing credentials were used in memory, not copied. Owned Gateway processes were stopped.
  • Fresh merged-candidate validation: all 14 focused hook/selector tests and all six recovery integration cases passed. Formatting passed, and fresh Codex/Sol Ultrafast review found no actionable P0–P2 findings in the eight-file candidate. The agents-tools typecheck and typed-lint preparation are locally blocked by the shared installation still providing proc-safe 0.3.0 while current main requires 0.4.1 (missing ProcessSnapshot fields in unchanged Darwin code); the installation was not mutated. Current-head CI must qualify that merged dependency context.
  • Current conflict repair integrates main 4238466. Earlier production/live evidence remains applicable only to the unchanged feature sources; fresh merged-candidate checks and exact-head PR CI qualify the integrated context.

Worked on by

Work sessions

roboclaw-bot and others added 2 commits October 18, 2026 20:09
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 8aabfbcb-0f39-413c-9e6f-bfc714cc090b
@clawsweeper

clawsweeper Bot commented Oct 18, 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.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 18, 2026 20:15
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: M labels Oct 18, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves producer-owned Code Mode checkpoint facts through output rewriting and transcript serialization.

Example: A replay-safe network_read call returns 30,000 characters, its output is wrapped and capped, and the Gateway restarts.

  • Before: Recovery cannot parse the displayed output as checkpoint JSON and loses the Code Mode recovery surface.
  • After: Recovery reads the persisted producer checkpoint and restores restricted exec/wait controls.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful boundary regressions and detailed reported live and upgrade results; no actionable defect found, with exact-head CI still pending.
Proof confidence 🐚 platinum hermit (4/6) This collaborator-authored bot PR is outside the ordinary contributor proof gate; its published evidence records real-model Gateway cold restarts, unchanged-effect rejection, and stable-release upgrade recovery, with subsequent feature-source identity verified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Safe interrupted Code Mode work loses recovery controls when hooks or network formatting rewrite its displayed checkpoint.
Reason: The maintainer-authored repair restores an existing recovery promise without adding configuration or changing ordinary permission policy.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current recovery defect, preserves existing recovery policy, and has no actionable correctness finding; exact-head CI remains pending.

Priority: P2
Reviewed head: e08d70ce976836af398c4ca312593e8091520732

Before merge

None.

Findings

None.

Agent review details

How this fits together

Code Mode produces execution results, the transcript guard carries private provenance into canonical storage, and restart recovery consumes the stored checkpoint to select continuation tools.

flowchart LR
  A[Code Mode executor] --> B[Private result provenance]
  B --> C[Output hooks and caps]
  C --> D[Canonical transcript storage]
  D --> E[Restart recovery policy]
  E --> F[Fresh restricted tool construction]
Loading

Technical review

Best possible solution:

Persist executor-owned checkpoint facts through the existing provenance and canonical append owners, retaining text parsing only for older stored transcripts.

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

Current-main source shows the failure: network-protected or truncated display text reaches a JSON-only checkpoint reader; the PR also records failing base regressions and real Gateway reproduction.

Is this the best way to solve the issue?

The patch fixes the producer-to-storage invariant rather than relaxing recovery parsing, reuses existing owners, and preserves the shipped legacy transcript contract.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Checkpoint reading and continuation policy keeps the original intent (1dcb35b: This commit moved the existing reader into a focused recovery module; it does not establish its original introduction. Subsequent recovery PRs document checkpoint-proven reconstruction and current-policy enforcement.)
  • Shared exec/wait result formatting keeps the original intent (91e1bed: Share result normalization and presentation while preserving runtime and cancellation behavior.)
  • Network-result provenance keeps the original intent (4cb9f12: Carry nested network-content facts privately through result transformations without losing taint.)
  • Canonical transcript serialization keeps the original intent (e40ed06: Preserve public custom-data JSON semantics while sharing immutable transcript payloads and reducing retained copies.)
  • Freshness-hook regression coverage keeps the original intent (fix: keep unresolved session owners from blocking authorized work #176401: Replace the removed pnpm option while retaining checks and arguments; the current diff preserves upstream production behavior and adds distinct regression coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +117, Tests +166, Docs +4. Total +287 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 120 3 +117
Tests 2 167 1 +166
Docs 1 6 2 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 293 6 +287

Review metrics

Metric Value Why it matters
Production versus test changes Production +120/-3; tests +167/-1. Production growth provides private checkpoint custody and canonical serialization stamping; tests cover recovery, forgery rejection, and retained hook behavior.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Wrapped or capped Code Mode results can disrupt restart continuation, with impact limited to interrupted checkpoint-bearing work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-18T20:31:43.687Z sha 450ee8b :: blocked before merge. :: none

Reviewed October 18, 2026, 5:29 PM ET / 21:29 UTC (Revision 2).

roboclaw-bot and others added 3 commits October 18, 2026 21:01
Resolve the shared freshness-hook conflicts with the upstream pnpm run invocation and both regression suites. Preserve the reviewed Code Mode production sources.

Co-authored-by: steipete <[email protected]>
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 528ef8af-ec0e-44a3-b109-70dc6f6eef0d
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Oct 18, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 18, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@roboclaw-bot
roboclaw-bot merged commit 771b787 into main Oct 18, 2026
146 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/pi-typed-recovery-facts branch October 18, 2026 21:36
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

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

* fix: preserve Code Mode recovery after wrapped tool output

Co-authored-by: steipete <[email protected]>

* fix: preserve Code Mode recovery after wrapped tool output

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 8aabfbcb-0f39-413c-9e6f-bfc714cc090b

* test: provide required plugin metadata in recovery fixture

Co-authored-by: steipete <[email protected]>

* Publish openclaw/pi-typed-recovery-facts

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 528ef8af-ec0e-44a3-b109-70dc6f6eef0d

---------

Co-authored-by: steipete <[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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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