Repository navigation
fix(code-mode): preserve file pages and handled error details - #140689
Conversation
Worked on by: - @Takhoffman Co-authored-by: Takhoffman <[email protected]> OpenClaw-Publication: 8a1fbeb6-e538-4431-b9f2-e0d6470f3069
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 12:24 AM ET / 04:24 UTC. ClawSweeper reviewWhat this changesThe PR separates structured file contents from display notices, preserves pagination continuations and handled error details, and prevents small read results from retaining large file buffers. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still mixes pagination notices into structured file results and loses handled error details. Both previous findings are resolved in the reviewed head, and no remaining blocking defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw Code Mode runs agent-written JavaScript in QuickJS and exposes existing tools through structured results. The file reader supplies bounded pages, while the guest output serializer returns values and diagnostics to the agent. flowchart LR
A[Agent JavaScript] --> B[Code Mode guest]
B --> C[File read tool]
C --> D[Bounded file page]
D --> E[File content and continuation]
D --> F[Human-readable display]
E --> B
B --> G[Serialized values and errors]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +81, Tests +307, Docs +18. Total +406 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep file-page ownership in the native reader and handled-error projection in the guest serializer, preserving explicit limits, bounded memory, and redaction. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the failure paths: current-main file pages embed display notices in structured content, and JSON serialization loses ordinary Error messages. No runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? Yes. The patch repairs the existing page and serialization owners, and the latest changes address both previously identified regressions without adding configuration or a competing implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 608b9ba2437d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Restore the pre-publication Android wrapper blob so this PR remains scoped to Code Mode file and error handling. Co-authored-by: Tak Hoffman <[email protected]>
Use the native reader limit normalization in the adaptive wrapper so zero and negative limits remain one-line reads instead of permitting automatic pagination. Worked on by: - @Takhoffman Co-authored-by: Takhoffman <[email protected]>
|
Addressed the normalized explicit-limit finding in a5c24bf. The wrapper now uses the native reader’s normalization before deciding whether to auto-page. The The previous head’s full CI/typechecks passed in https://github.com/openclaw/openclaw/actions/runs/34079303018. I will not use that run as proof for the new head; fresh CI is running. The PR body now records the fix and validation accurately. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Preserve main's allocation-free line scanning and bounded UTF-16 copies while keeping structured file data separate from display notices and retaining partial-page continuation metadata. Worked on by: - @Takhoffman Co-authored-by: Takhoffman <[email protected]>
Detach both bounded text channels independently of EOF classification so small explicit pages cannot retain the decoded source file. Preserve UTF-16 code units and continuation metadata. Add real-reader GC regressions for line, range, and cursor selections. Worked on by: - @Takhoffman Co-authored-by: Takhoffman <[email protected]>
|
Fixed the integrated reader retention finding in Added real-reader GC regression cases for explicit line, multi-line range, and cursor selections. All three failed before the fix: eight small retained results kept 16,777,256 bytes of external backing. After the fix all three pass; a separate line measurement reports 72,880 bytes heap growth and 40 bytes external growth. Assertions run only after GC so inspecting returned strings cannot hide retention. Content (including lone surrogates) and continuation metadata are also verified. Current proof: 3 retained-memory cases + 55 native reader + 27 filesystem/Code Mode contract tests passed; targeted lint and fresh P0–P2 autoreview are clean. The preceding integration head passed full CI run 34081289327; new exact-head CI is required for this fix. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Annotate the independently constructed string expectation so the production typecheck does not encounter circular assertion inference. Runtime behavior and memory assertions are unchanged. Worked on by: - @Takhoffman Co-authored-by: Takhoffman <[email protected]>
|
Merged via squash.
|
…aw#140689) Preserve structured file pages and continuation metadata for Code Mode, independently bound file data and display output, retain actionable handled-error diagnostics before serialization, and honor normalized explicit read limits. Preserve existing redaction and execution controls. Worked on by: - @Takhoffman Co-authored-by: Takhoffman <[email protected]> Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
What Problem This Solves
Resolves a problem where agents using Code Mode could not reliably parse paginated files or inspect handled tool failures. File text was mixed with display-only notices, some partial reads looked complete, and caught Error values lost their actionable messages.
Why This Change Was Made
Keep structured file data separate from human-readable display text, carry continuation metadata through explicit limits and tighter read budgets, and normalize handled Errors before output serialization. Blank pages use the same page owner. Both displayed and structured content remain budgeted, and existing
.envredaction is preserved on both channels.This changes OpenClaw’s implementation, not model-specific prompts or provider policies. It adds no configuration, dependencies, storage schema, or permission changes.
User Impact
Promise.allSettledreasons; Error-specifictoJSONmethods cannot hide the diagnostic.Evidence
exec,wait, and headless execution, including a customtoJSONcase.Live acceptance for the main Code Mode repair (before the small normalized-limit follow-up):
kimi/k3zai/glm-5.2These are bounded functional trials, not a general model benchmark. Fresh independent review was scoped-clean at P0–P2 after all actionable findings were repaired.
Focused reproduction commands:
node scripts/run-vitest.mjs src/agents/code-mode.rejections.test.ts src/agents/code-mode.guest.test.ts src/agents/filesystem-tools-output-contract.test.ts src/agents/sessions/tools/read.test.ts node scripts/run-vitest.mjs src/agents/agent-tools.create-openclaw-coding-tools.test.ts -t readHosted validation and resolved review findings
Final head
9294da3f54abc15ad64597f361deb6e84f6c2946passed full hosted CI, including production/test typechecks and the requiredopenclaw/ci-gate: https://github.com/openclaw/openclaw/actions/runs/34082597388. ClawSweeper reviewed this exact head, confirmed both previous findings resolved, and reported no actionable defects: #140689 (comment).Live model trials predate the small follow-ups; those follow-ups have direct regression proof plus final-head CI. Local full typechecking was blocked by pnpm bootstrap age policy and the shared-dependency guard; hosted CI supplied that proof without weakening either guard.
Worked on by:
View the OpenClaw team session