openclaw - 💡(How to fix) Fix JSON Parser Crash on Em-Dash Characters in Edit Tool Arguments (silent session death, no error) [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#60002Fetched 2026-04-08 02:37:39
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

OpenClaw experiences a critical bug where the JSON parser crashes the entire agent session when an em-dash character (U+2014, —) is included in the arguments of an edit tool call, specifically within the oldText or newText parameters. This results in instant session termination with no error messages, log output, or recovery options.

Error Message

OpenClaw experiences a critical bug where the JSON parser crashes the entire agent session when an em-dash character (U+2014, —) is included in the arguments of an edit tool call, specifically within the oldText or newText parameters. This results in instant session termination with no error messages, log output, or recovery options.

  • Subsequent attempts to edit files containing em-dashes trigger a JSON parse error in OpenClaw's tool call handler
  1. Observe the session crash instantly with no error output The edit tool call should process the em-dash argument successfully and continue the session. Any parsing errors should be handled gracefully with appropriate logging and error reporting. The JSON parser fails on the em-dash character, causing the entire agent session to crash instantly. No error messages or logs are produced. There is no mechanism for recovery or debugging. The session simply stops responding.

Root Cause

Root Cause Chain

Fix Action

Fix / Workaround

  • 9 confirmed crashes between March 22 and April 1, 2026
  • 6 crashes in a single day (April 1, 2026)
  • All crashes were completely silent -- no errors, no logs, no indication of cause
  • Root cause took multiple days to diagnose due to the silent failure mode
  • Workaround required banning em-dashes globally across all agent system prompts, outputs, and workspace files

Current Workaround

RAW_BUFFERClick to expand / collapse

Description

OpenClaw experiences a critical bug where the JSON parser crashes the entire agent session when an em-dash character (U+2014, —) is included in the arguments of an edit tool call, specifically within the oldText or newText parameters. This results in instant session termination with no error messages, log output, or recovery options.

Root Cause Chain

  • AI models (e.g. Anthropic Claude) frequently generate em-dashes in natural language prose (briefs, plans, comments)
  • Agents incorporate this text into source files using the edit tool
  • Subsequent attempts to edit files containing em-dashes trigger a JSON parse error in OpenClaw's tool call handler
  • The session terminates immediately and silently, providing no diagnostic information

Steps to Reproduce

  1. Start an OpenClaw agent session using an Anthropic Claude model (Sonnet 4.6 or Haiku 4.5)
  2. Instruct the agent to write text containing an em-dash to a file using the edit tool (e.g. oldText: "This is a test — with an em-dash.")
  3. Instruct the agent to make a follow-up edit that includes the em-dash character in oldText or newText
  4. Observe the session crash instantly with no error output

Expected Behavior

The edit tool call should process the em-dash argument successfully and continue the session. Any parsing errors should be handled gracefully with appropriate logging and error reporting.

Actual Behavior

The JSON parser fails on the em-dash character, causing the entire agent session to crash instantly. No error messages or logs are produced. There is no mechanism for recovery or debugging. The session simply stops responding.

Impact

  • 9 confirmed crashes between March 22 and April 1, 2026
  • 6 crashes in a single day (April 1, 2026)
  • All crashes were completely silent -- no errors, no logs, no indication of cause
  • Root cause took multiple days to diagnose due to the silent failure mode
  • Workaround required banning em-dashes globally across all agent system prompts, outputs, and workspace files

The silent failure aspect is the most severe part of this bug. There is no way to distinguish a crashed session from a slow one until it becomes clear the agent is gone.

Affected Versions

  • Confirmed affected: OpenClaw v2026.3.31
  • Unknown: OpenClaw v2026.4.2 (recently upgraded; not yet verified)

Has this been addressed in v2026.4.2? If not, we would appreciate guidance on any planned fix or additional testing steps we can run to help confirm.

Environment

  • OS: Linux 6.17.0-20-generic (x64)
  • Node.js: v24.14.1
  • Shell: bash
  • Agent models affected: Anthropic Claude Sonnet 4.6, Anthropic Claude Haiku 4.5
  • Tool affected: edit (file editing tool)
  • Character: em-dash U+2014 (—)

Current Workaround

Banned em-dash characters from all agent outputs, code comments, tool arguments, and workspace files. Added a hard rule to all agent system prompts prohibiting em-dash generation. Effective but limits natural language expressiveness and requires permanent enforcement overhead.

We are happy to provide additional logs, session transcripts, or testing support to help reproduce and resolve this.


Reported by OpenSpek -- building autonomous multi-agent development pipelines on OpenClaw.

extent analysis

TL;DR

The most likely fix involves updating the JSON parser in OpenClaw to properly handle the em-dash character (U+2014) in the oldText and newText parameters of the edit tool call.

Guidance

  • Verify if the issue is resolved in OpenClaw v2026.4.2 by testing the edit tool with em-dash characters in the oldText and newText parameters.
  • If the issue persists, consider implementing a temporary workaround by escaping or replacing em-dash characters in the oldText and newText parameters before passing them to the JSON parser.
  • Investigate the JSON parser library used by OpenClaw to determine if there are any known issues or updates that address Unicode character handling.
  • Test the edit tool with other Unicode characters to ensure that the issue is specific to the em-dash character and not a broader problem with Unicode support.

Example

// Example of escaping em-dash characters in oldText and newText parameters
const oldText = "This is a test — with an em-dash.".replace(//g, "\\u2014");
const newText = "This is a test — with an em-dash.".replace(//g, "\\u2014");
// Pass oldText and newText to the edit tool

Notes

The current workaround of banning em-dash characters may not be sustainable, and a more robust solution is needed to handle Unicode characters in the edit tool. The issue may be specific to the JSON parser library used by OpenClaw, and investigating updates or alternative libraries may provide a solution.

Recommendation

Apply a workaround by escaping or replacing em-dash characters in the oldText and newText parameters until a permanent fix is available in a future version of OpenClaw. This will allow for continued use of the edit tool while minimizing the impact of the em-dash character 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