Skip to content

fix: stop Code Mode after tool reply decoding runs out of memory - #188023

Merged
vincentkoc merged 1 commit into
mainfrom
fix/code-mode-reply-decoding-oom
Oct 30, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/code-mode-reply-decoding-oom

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes Code Mode silently treating a tool result as a string and running later tools when QuickJS runs out of memory while decoding that result.

User Impact

The affected cell now fails visibly and stops subsequent effects. The original tool may already have executed; this change does not roll back completed tools. No configuration, default, dependency, or migration changes.

Why This Change Was Made

The shared reply decoder caught every JSON parsing failure and resolved the tool promise with raw JSON text. All production reply producers encode JSON, so the fallback violated the result contract. Let the existing checked worker settlement terminate the cell on decoding failure.

The fix removes six net production lines. Regressions cover public exec completion and delivery after an explicit public checkpoint, exact-once tool execution, suppression of a later sentinel tool, cleanup, and fresh-cell recovery. Existing guest-caught allocation OOM behavior remains covered.

Evidence

  • Negative control: a reply containing 500,000 empty objects (1,500,001 JSON bytes) under a 16 MiB QuickJS heap completed as { array: false, length: 1500001 } and ran the sentinel tool in both routes. Both unchanged regression cases fail against the original decoder.
  • Fixed head 05fa4fc7d8105cf1b6d52ab205b05d7a7baa90ea, tree 9e6d5ffc6cf9818ecb658c704c487f0d1e52a6fa: 91 tests passed across QuickJS integration, Node/QuickJS parity, failure phases, and reply inbox accounting. Targeted typecheck and lint passed on the same source; formatting passed.
  • Proof ran on Blacksmith Testbox workflow 40986440574, lease tbx_01m656zcsyx8kccr0w5wsfkdwr, with native command exit 0. The holder workflow may show cancelled after lease cleanup.
  • Independent autoreview at P0–P2: scoped-clean, no actionable findings. Reviewed the local fix against 7fdbd694e6723bdc9e3baa6b6df9fba9b5501f23; transferred the identical three-file patch onto pinned main f126f05fd9521e2977f2b7921ff49522fde0b552. The reviewed decoder/caller contexts are unchanged across those bases. Local ClawSweeper has no clean runner checkout; hosted review follows the maintainer fallback route.
  • This is correctness proof. It makes no new performance, ShellBench, packaged-runtime, or live-Gateway claim. Unchecked value construction in quickjs-wasi remains a separate investigation.

@vincentkoc vincentkoc self-assigned this Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 30, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review October 30, 2026 01:38
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 30, 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-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@vincentkoc
vincentkoc merged commit 9ca944e into main Oct 30, 2026
196 checks passed
@vincentkoc
vincentkoc deleted the fix/code-mode-reply-decoding-oom branch October 30, 2026 01:52
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

amittell pushed a commit to amittell/openclaw that referenced this pull request Nov 16, 2026
amittell added a commit to amittell/openclaw that referenced this pull request Nov 16, 2026
Alex, room openclaw#620. Of the 72 11.3..11.4 commits the census counted as
production changes, six main fixes are ported: openclaw#187499, openclaw#187653, openclaw#188023,
openclaw#195400, openclaw#196297 and openclaw#197960. PORTING-NOTES.md, "The 72 11.4 repairs
reviewed against the carry", records each deferral with its reason, the two
UNSURE outcomes, and the M4 qualification.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant