openclaw - 💡(How to fix) Fix Control UI: JSON parse error when tool output contains multiline strings or special characters [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63315Fetched 2026-04-09 07:55:22
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

The Control UI crashes with a JSON parse error when rendering a session message that contains tool output with multiline strings, escaped characters, or large file content (e.g. a Python script written via the write tool).

Error Message

SyntaxError: Expected ',' or '}' after property value in JSON at position 1299

The UI fails to render the entire message block containing the offending tool output. Surrounding messages are unaffected.

Root Cause

The Control UI crashes with a JSON parse error when rendering a session message that contains tool output with multiline strings, escaped characters, or large file content (e.g. a Python script written via the write tool).

Code Example

SyntaxError: Expected ',' or '}' after property value in JSON at position 1299
RAW_BUFFERClick to expand / collapse

Summary

The Control UI crashes with a JSON parse error when rendering a session message that contains tool output with multiline strings, escaped characters, or large file content (e.g. a Python script written via the write tool).

Error

SyntaxError: Expected ',' or '}' after property value in JSON at position 1299

The UI fails to render the entire message block containing the offending tool output. Surrounding messages are unaffected.

Repro Steps

  1. In any session, use the write tool to create a file with multiline content (e.g. a Python script with docstrings, apostrophes, or backslashes)
  2. The assistant response containing that tool call renders with a JSON parse error in the Control UI
  3. The tool itself runs successfully — this is a display/rendering issue only

Example

Trigger was writing a Python script via the write tool. The script contained triple-quoted docstrings, apostrophes in comments, and backslashes in string formatting. Cron job update calls that followed (containing long prompt strings with apostrophes) may also contribute.

Expected Behavior

The Control UI should safely handle tool output containing arbitrary text content, including multiline strings, special characters, and escaped sequences, without breaking the message renderer.

Suggested Fix

Wrap the tool output content in a try/catch when parsing, or sanitize/escape the content before passing it to the JSON renderer. A fallback raw-text view for unparseable tool output would also be acceptable.

Environment

  • OpenClaw version: 2026.4.2
  • Platform: Linux (Beelink, x64)
  • Node: v22.22.0
  • Channel: webchat (Control UI)

extent analysis

TL;DR

The Control UI can be fixed by properly sanitizing or escaping tool output content before passing it to the JSON renderer to prevent JSON parse errors.

Guidance

  • Verify that the issue is indeed caused by the JSON parse error by checking the error message and the position of the error (in this case, position 1299).
  • Sanitize or escape the tool output content before passing it to the JSON renderer to prevent special characters from causing parse errors.
  • Consider implementing a try/catch block when parsing the tool output to catch and handle any parse errors that may occur.
  • As a fallback, provide a raw-text view for unparseable tool output to ensure that the message is still displayed, even if it cannot be rendered as JSON.

Example

// Example of sanitizing tool output content
const sanitizedOutput = toolOutput.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/'/g, '\\\'');

Notes

The provided solution assumes that the issue is caused by the JSON parse error and that sanitizing or escaping the tool output content will fix the issue. However, the root cause of the issue may be more complex and require additional debugging.

Recommendation

Apply a workaround by sanitizing or escaping the tool output content before passing it to the JSON renderer, as this is a more straightforward and immediate solution that can be implemented without requiring a full understanding of the underlying issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING