Skip to content

fix: identify malformed Code Mode JavaScript as input errors - #149222

Merged
RomneyDa merged 2 commits into
mainfrom
openclaw/fix-code-mode-syntax-input-ready
Sep 21, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
openclaw/fix-code-mode-syntax-input-ready

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: Code Mode reports an internal runtime failure when model-generated JavaScript contains malformed nested quotes or another syntax error, even though no tool ran.

User Impact

User impact: the model receives a bounded syntax diagnostic with a source line and column and explicit no-dispatch evidence, so it can correct the source and continue. No configuration or migration is required.

Why This Change Was Made

Source preparation rejects malformed JavaScript through the existing input-error contract before creating the guest VM. Module and shell guards keep their precedence. Valid code that throws a runtime exception remains a runtime failure; source is never automatically repaired or replayed, and restartSafe/replaySafe behavior is unchanged.

The September 21 conflict resolution preserves main's synchronous, JavaScript-only source owner and its module-scan shortcut. It does not restore retired TypeScript execution or add another repair loop. The parser result is shared between syntax validation and module checks.

Evidence

  • Original registered-exec regression failed before the repair: zero dispatches, but internal_error/guest rather than invalid_input/input. Corrected follow-up dispatches exactly once.
  • Refreshed focused guest, source-validation, headless and replay coverage: 319 tests passed across five files. Serial measurement: 22.64 seconds wall, 21.24 seconds Vitest duration.
  • Tests cover bounded duplicate-identifier diagnostics and runtime-thrown SyntaxError remaining a runtime failure.
  • Fresh independent autoreview of the resolved patch: no actionable P0–P2 findings.
  • Rebased onto main be3d22b. Three conflicts were resolved semantically; range-diff preserves the feature and adapts tests/docs to the current source API.
  • Full refreshed changed checks passed, including core/core-test typechecks, lint, formatting, dead-code scans and repository guards.
  • Exact-head CI run succeeded: https://github.com/openclaw/openclaw/actions/runs/35585084702. The checks-node-changed job took 91 seconds; this is job-level cost, not the duration of these tests alone.
  • ClawSweeper reviewed final head 6dab4c2: platinum hermit (4/6), no actionable code or security findings. Review: fix: identify malformed Code Mode JavaScript as input errors #149222 (comment)
  • The final metadata-only rewrite groups both coauthor entries as recognized Git trailers. The reviewed/tested source tree is unchanged: d7b67eaf636dfc1fdc891715a05096ab7402ed75.

This is a runtime diagnostic change, not a visual UI change. No merge or deployment is requested.

Contributor credit: Dallin Romney (@RomneyDa). Both authorized coauthor trailers are preserved on every commit.

Work sessions

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 15, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/fix-code-mode-syntax-input-ready branch from 71c00d2 to b3c6175 Compare September 15, 2026 15:44
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 15, 2026 15:53
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 6:22 AM ET / 10:22 UTC (Revision 5).

ClawSweeper review

What this changes

Code Mode rejects malformed JavaScript before guest execution and returns bounded input-error diagnostics, with updated regression tests and troubleshooting guidance.

Merge readiness

✅ Ready for maintainer review

The fix remains useful: current main still classifies malformed JavaScript as a guest runtime failure. No actionable correctness or security findings remain, and the protected maintainer label excludes cleanup closure.

Priority: P2
Reviewed head: 6dab4c2968f4515ce327a508b13dc44055920602

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful boundary regression coverage and no actionable findings; reported tests were not rerun here.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor proof gate does not apply to this repository-managed bot PR. Registered-exec and headless tests cover the changed source-preparation path, but their reported passes are supplemental testing, not independently observed live proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor proof gate does not apply to this repository-managed bot PR. Registered-exec and headless tests cover the changed source-preparation path, but their reported passes are supplemental testing, not independently observed live proof.
Evidence reviewed 8 items Pinned introduced change: Reviewed the merge-base-to-head patch. Production changes are confined to the existing source-preparation owner; endpoint drift was not attributed to this PR.
Current-main necessity: Current main's prepareSource checks module access and shell-like input, then returns the source without rejecting ordinary parser failures. The central diagnostic correction is still absent.
Latest-release comparison: The JavaScript branch in v2026.9.5 also returns malformed source after module and shell checks; it does not contain this early syntax-error classification.
Findings None None.
Security None None.

How this fits together

OpenClaw Code Mode accepts model-generated JavaScript and runs it in an isolated QuickJS worker that can request enabled tools. Source preparation checks the program before execution and returns errors to the model for correction.

flowchart TD
  A[Model submits JavaScript] --> B[Source preparation]
  B --> C{Valid permitted source?}
  C -->|No| D[Bounded input diagnostic]
  C -->|Yes| E[Isolated QuickJS worker]
  E --> F[Enabled tool dispatch]
  E --> G[Result or runtime failure]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +10, Tests +37, Docs +7. Total +54 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 3 +10
Tests 3 64 27 +37
Docs 1 8 1 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 85 31 +54

Review metrics

Metric Value Why it matters
Source parsing 1 Acorn parse per exec, including module-free JavaScript Early diagnostics replace main's parser bypass while sharing the parsed result with module validation.

Technical review

Best possible solution:

Keep syntax classification in the existing source-preparation owner, preserving no-dispatch evidence and the distinction between malformed source and runtime exceptions.

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

Yes, from source: submitting malformed JavaScript through Code Mode exec reaches guest parsing on current main and receives a runtime failure classification. The registered-exec regression covers that path; it was not run during this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the existing parser and input-error contract is a focused repair that preserves guard precedence and runtime exceptions; it adds parsing work for cells that previously bypassed Acorn.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This corrects recoverable error classification in optional Code Mode without changing configuration or tool permissions.
  • 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 ordinary external-contributor proof gate does not apply to this repository-managed bot PR. Registered-exec and headless tests cover the changed source-preparation path, but their reported passes are supplemental testing, not independently observed live proof.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head patch. Production changes are confined to the existing source-preparation owner; endpoint drift was not attributed to this PR. (src/agents/code-mode-source.ts:109, 6dab4c2968f4)
  • Current-main necessity: Current main's prepareSource checks module access and shell-like input, then returns the source without rejecting ordinary parser failures. The central diagnostic correction is still absent. (src/agents/code-mode-source.ts:107, ffb50bc0479d)
  • Latest-release comparison: The JavaScript branch in v2026.9.5 also returns malformed source after module and shell checks; it does not contain this early syntax-error classification. (src/agents/code-mode-source.ts, ec9c1a13db89)
  • Error classification and dispatch boundary: The worker calls prepareSource before creating the VM. Its existing catch maps ToolInputError to invalid_input, and failedWorkerResult records the input phase with bridgeDispatchStarted false. Runtime-thrown guest exceptions retain their separate failure path. (src/agents/code-mode.worker.ts:567, 6dab4c2968f4)
  • Behavioral regression coverage: The registered-exec regression checks malformed nested quotes, zero dispatches, unchanged replay safety, cleanup, and exactly one dispatch after correction. Separate cases preserve runtime-thrown SyntaxError classification and bound long parser diagnostics. The captured PR body reports 319 passing tests and 22.64 seconds wall time; this read-only review did not execute them. (src/agents/code-mode.guest.test.ts:741, 6dab4c2968f4)
  • Implementation boundary: The documentation explicitly separates OpenClaw's JSON-input QuickJS worker from Codex's native Code Mode. The changed owner uses OpenClaw's existing Acorn parser; no Codex harness dependency signal applies. Public docs: docs/tools/code-mode.md. (docs/tools/code-mode.md:26, 6dab4c2968f4)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-15T15:58:40.400Z sha b3c6175 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T21:10:06.812Z sha b3c6175 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T09:35:28.264Z sha 1af425eed0487764fecd6d7582276417545c6e96 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T09:55:15.256Z sha 6dab4c2 :: needs maintainer review before merge. :: none

@fuller-stack-dev fuller-stack-dev self-assigned this Sep 18, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/fix-code-mode-syntax-input-ready branch from b3c6175 to 1af425e Compare September 21, 2026 09:27
roboclaw-bot and others added 2 commits September 21, 2026 09:45
Reject syntax errors before guest execution and preserve authoritative no-dispatch evidence without changing restart-safe policy.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/fix-code-mode-syntax-input-ready branch from 1af425e to 6dab4c2 Compare September 21, 2026 09:45
@RomneyDa
RomneyDa enabled auto-merge (squash) September 21, 2026 11:37
@RomneyDa
RomneyDa merged commit fe70f19 into main Sep 21, 2026
111 checks passed
@RomneyDa
RomneyDa deleted the openclaw/fix-code-mode-syntax-input-ready branch September 21, 2026 11:37
vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit '0883394977d1fb3af657635967f6e447bd7fff9a': (72 commits)
  fix(ui): await scheduled rail layout in focus test
  fix(cron): keep healthy active runs from delaying job lists (#154421)
  fix(plugins): prevent config conflicts during legacy plugin installation (#154539)
  perf(gateway): reduce repeated session-list work (#154551)
  fix(tasks): retain admitted work across list retries (#154338)
  perf(gateway): speed up transcript artifact downloads (#154726)
  chore(ui): refresh control ui locales (#154580)
  fix(release): keep two extended-stable months eligible (#154777)
  fix(tests): avoid avatar descriptor reuse race (#154747)
  perf(plugins): reduce callback scope overhead (#154625)
  fix(ui): include final request time in completed work summaries (#149240)
  fix(ai): avoid retrying conflicting Responses terminal statuses (#149242)
  fix: identify malformed Code Mode JavaScript as input errors (#149222)
  fix(doctor): settle imported JSONL transcript leftovers (#154413)
  fix(cloud): restore node bootstrap with bundled browser runtime (#154654)
  test(ui): await publication state notifications (#154768)
  fix(plugins): keep unchanged plugins running across metadata refreshes (#151281)
  fix: keep chat panel accessibility targets within each pane (#153478)
  fix: forced Gateway restarts cancel healthy subagent work (#154300)
  improve: reduce session delivery reader imports (#154740)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…w#149222)

* fix: identify malformed Code Mode JavaScript as input errors

Reject syntax errors before guest execution and preserve authoritative no-dispatch evidence without changing restart-safe policy.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>

* fix: identify malformed Code Mode JavaScript as input errors

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: Dallin Romney <[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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

3 participants