openclaw - 💡(How to fix) Fix [Feature]: memory_get JSON parse errors silently kill tool requests with no error visibility [2 comments, 3 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#71680Fetched 2026-04-26 05:09:52
View on GitHub
Comments
2
Participants
3
Timeline
4
Reactions
0
Timeline (top)
commented ×2closed ×1labeled ×1

When MEMORY.md contains special characters (em-dashes, curly quotes, etc.), memory_get fails with JSON parse error on the backend silently. OpenClaw never see an error.

Error Message

When MEMORY.md contains special characters (em-dashes, curly quotes, etc.), memory_get fails with JSON parse error on the backend silently. OpenClaw never see an error. Problem: When MEMORY.md contains special characters (em-dashes, curly quotes, etc.), memory_get fails with JSON parse error on the backend, Impact: The entire request dies silently — OpenClaw never see an error, the tool just stops responding, Expected: Either handle the parse error gracefully, OR return an error response so I can see what went wrong, Option 1 (Preferred): Wrap memory_get JSON parsing in a try-catch and return structured error responses: "status": "error", "error": "JSON parse failed", If JSON parse takes >1s, abort and return error instead of hanging, No error message, no fallback, no visibility, User gets incomplete responses with no error explanation, Developer cannot debug — no logs, no error message, request just dies, Error: Expected ',' or '}' after property value in JSON at position 1140 Error: Smart quotes " " + em-dash — trigger JSON parse failure Result: Silent tool death, request produces no error response Error logged by OpenClaw: "Expected ',' or ']' after array element in JSON at position 1385" rsync error: /Users/.../Library/Mobile Documents/.../baseline.zip: mmap: Resource deadlock avoided Tool-side error, no recovery path memory_get returns: { status: "error", reason: "...", fallback: "use read" }

Root Cause

Recommendation: Option 1 is best because it solves the root problem (silent failures) while giving callers a graceful fallback path.

Fix Action

Fix / Workaround

Tool: memory_get, Problem: When MEMORY.md contains special characters (em-dashes, curly quotes, etc.), memory_get fails with JSON parse error on the backend, Impact: The entire request dies silently — OpenClaw never see an error, the tool just stops responding, Expected: Either handle the parse error gracefully, OR return an error response so I can see what went wrong, Workaround: Use read tool instead

Option 3 (Workaround): Document that memory_get is incompatible with files containing special characters, and recommend read for MEMORY.md specifically.

Consequence: Agent turns hang or timeout silently, User gets incomplete responses with no error explanation, Developer cannot debug — no logs, no error message, request just dies, Forces workaround (avoid memory_get, use less-efficient read tool), Degrades user trust in agent reliability, Wastes tokens on timeout retries with no actionable failure info,

Code Example

If JSON parse fails:
  Return: {
    "status": "error",
    "tool": "memory_get",
    "error": "JSON parse failed",
    "reason": "File content contains characters incompatible with JSON serialization",
    "fallback": "Use 'read' tool instead for reliable file access"
  }
RAW_BUFFERClick to expand / collapse

Summary

When MEMORY.md contains special characters (em-dashes, curly quotes, etc.), memory_get fails with JSON parse error on the backend silently. OpenClaw never see an error.

Problem to solve

Tool: memory_get, Problem: When MEMORY.md contains special characters (em-dashes, curly quotes, etc.), memory_get fails with JSON parse error on the backend, Impact: The entire request dies silently — OpenClaw never see an error, the tool just stops responding, Expected: Either handle the parse error gracefully, OR return an error response so I can see what went wrong, Workaround: Use read tool instead

Proposed solution

Option 1 (Preferred): Wrap memory_get JSON parsing in a try-catch and return structured error responses:

If JSON parse fails:
  Return: {
    "status": "error",
    "tool": "memory_get",
    "error": "JSON parse failed",
    "reason": "File content contains characters incompatible with JSON serialization",
    "fallback": "Use 'read' tool instead for reliable file access"
  }

This way:

  • I get visibility into the failure
  • I can fall back to read automatically
  • The request doesn't die silently

Option 2 (Simpler): Sanitize/escape special characters in memory_get output before JSON encoding, so em-dashes, curly quotes, etc. don't break parsing.

Option 3 (Workaround): Document that memory_get is incompatible with files containing special characters, and recommend read for MEMORY.md specifically.


Recommendation: Option 1 is best because it solves the root problem (silent failures) while giving callers a graceful fallback path.

Alternatives considered

Alt 1: Strict mode flag Add strict: false param to memory_get that sanitizes output instead of failing, Pro: Backward compatible, opt-in, Con: Doesn't solve the root problem, just hides it,

Alt 2: Stream large files instead of JSON Return file content as streaming chunks rather than a single JSON object, Pro: Handles arbitrarily large/complex files, Con: Changes tool API significantly, breaks existing callers,

Alt 3: Base64-encode problematic content Detect parse failures, re-encode output as base64, return that, Pro: Preserves data losslessly, Con: Requires caller to decode, adds complexity,

Alt 4: Use text extraction instead of JSON Return structured metadata (path, size, encoding) + raw text separately, not JSON, Pro: Natural for text files, no serialization needed, Con: Requires new tool design, incompatible with current API,

Alt 5: Fail fast with timeout If JSON parse takes >1s, abort and return error instead of hanging, Pro: Prevents silent timeout hangs, Con: Doesn't solve the parse failure itself, just makes it visible

Impact

Affected: Any agent using memory_get on files with special characters (em-dashes, curly quotes, Unicode), MEMORY.md specifically (common use case for storing long-term context), Any workflow that relies on memory_get for session context retrieval,

Severity: High — Silent tool failure = unrecoverable agent state, No error message, no fallback, no visibility, Breaks core functionality (memory access) with zero feedback,

Frequency: Common — MEMORY.md naturally accumulates special characters from conversational context, Happens whenever file contains: — (em-dash), " " (curly quotes), ' ' (smart quotes), etc., Affects any user documenting decisions/context with natural prose,

Consequence: Agent turns hang or timeout silently, User gets incomplete responses with no error explanation, Developer cannot debug — no logs, no error message, request just dies, Forces workaround (avoid memory_get, use less-efficient read tool), Degrades user trust in agent reliability, Wastes tokens on timeout retries with no actionable failure info,

Evidence/examples

Example 1: MEMORY.md with em-dashes

2026-04-25 — Mac Mini Infrastructure Rule

  • ALL local Mac tasks use Mac cron, NOT OpenClaw gateway cron
  • Reason: gateway cron had stability issues; Mac cron is independent and reliable

Error: Expected ',' or '}' after property value in JSON at position 1140 Result: memory_get fails silently, agent cannot fetch context

Example 2: Natural language in memory files feedback: "Pretty cool" — wants voice quality improved before showing anyone

Error: Smart quotes " " + em-dash — trigger JSON parse failure Result: Silent tool death, request produces no error response

Example 3: Real reproduction (from user session) Tool call: memory_get(path="MEMORY.md", from=1, lines=50) Response: [TIMEOUT / NO RESPONSE] Error logged by OpenClaw: "Expected ',' or ']' after array element in JSON at position 1385" Agent perspective: Tool never returned, turn hangs

Example 4: Backup script failure (parallel issue)

rsync error: /Users/.../Library/Mobile Documents/.../baseline.zip: mmap: Resource deadlock avoided Tool-side error, no recovery path Script must be manually fixed with excludes

Example 5: Expected vs. actual behavior Expected: memory_get returns: { status: "error", reason: "...", fallback: "use read" }

Actual: memory_get returns: [SILENCE] Agent: [HANGS OR TIMES OUT]

Additional information

No response

extent analysis

TL;DR

The most likely fix is to wrap memory_get JSON parsing in a try-catch block and return a structured error response when parsing fails.

Guidance

  • Identify the root cause of the JSON parse error by checking the MEMORY.md file for special characters such as em-dashes and curly quotes.
  • Implement a try-catch block around the JSON parsing code in memory_get to catch and handle parse errors.
  • Return a structured error response with a clear error message, reason, and fallback option when a parse error occurs.
  • Consider sanitizing or escaping special characters in the MEMORY.md file content before JSON encoding as an alternative solution.

Example

try:
    # JSON parsing code here
    json_data = json.loads(memory_get_output)
except json.JSONDecodeError as e:
    return {
        "status": "error",
        "tool": "memory_get",
        "error": "JSON parse failed",
        "reason": "File content contains characters incompatible with JSON serialization",
        "fallback": "Use 'read' tool instead for reliable file access"
    }

Notes

The proposed solution assumes that the memory_get tool is designed to handle JSON output. If the tool is not intended to handle JSON, an alternative solution such as returning the file content as plain text or streaming chunks may be more suitable.

Recommendation

Apply the workaround by wrapping memory_get JSON parsing in a try-catch block and returning a structured error response, as it provides a clear and actionable error message and fallback option.

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