openclaw - 💡(How to fix) Fix Embedded agent JSON parse error during tool completion (position 1246) [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#69762Fetched 2026-04-22 07:48:33
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
2
Participants

Occasional JSON parse error when embedded agent completes a tool call (specifically edit tool). Error does not prevent tool execution — the work completes successfully, but logging fails.

Error Message

Expected ',' or ']' after array element in JSON at position 1246 (line 1 column 1247)

Root Cause

Occasional JSON parse error when embedded agent completes a tool call (specifically edit tool). Error does not prevent tool execution — the work completes successfully, but logging fails.

Code Example

Expected ',' or ']' after array element in JSON at position 1246 (line 1 column 1247)

---

{"event":"embedded_run_agent_end","tags":["error_handling","lifecycle","agent_end","assistant_error"],"runId":"2e96dc5d-a683-4af5-a2fe-c6a2ac5e9869","isError":true,"error":"Expected ',' or ']' after array element in JSON at position 1246 (line 1 column 1247)","failoverReason":null,"model":"claude-haiku-4-5","provider":"anthropic","rawErrorHash":"sha256:e6155f3b4820","providerRuntimeFailureKind":"unknown"}

---

/tmp/openclaw/openclaw-2026-04-21.log
RAW_BUFFERClick to expand / collapse

Summary

Occasional JSON parse error when embedded agent completes a tool call (specifically edit tool). Error does not prevent tool execution — the work completes successfully, but logging fails.

Error

Expected ',' or ']' after array element in JSON at position 1246 (line 1 column 1247)

Details

  • Model: claude-haiku-4-5 (Anthropic)
  • Provider: anthropic
  • Tool: edit (file editing)
  • Frequency: Multiple times per session (28 occurrences on 2026-04-21)
  • Impact: Non-blocking — tool call succeeds, file persists correctly, but error is logged
  • Runtime Failure Kind: unknown (per logs)

Logs

Error appears in /tmp/openclaw/openclaw-*.log with event type embedded_run_agent_end and isError=true.

Example log entry (UTC 2026-04-21T15:18:09.855Z):

{"event":"embedded_run_agent_end","tags":["error_handling","lifecycle","agent_end","assistant_error"],"runId":"2e96dc5d-a683-4af5-a2fe-c6a2ac5e9869","isError":true,"error":"Expected ',' or ']' after array element in JSON at position 1246 (line 1 column 1247)","failoverReason":null,"model":"claude-haiku-4-5","provider":"anthropic","rawErrorHash":"sha256:e6155f3b4820","providerRuntimeFailureKind":"unknown"}

Hypothesis

The error occurs during JSON serialization of tool call parameters or response context. The actual LLM request JSON is not being logged, so it's unclear whether:

  1. My tool parameter JSON is malformed (unlikely — tool calls execute)
  2. OpenClaw's metadata wrapper is breaking JSON structure
  3. There's an issue in the logging serialization layer itself

Reproduction

Occurs during normal tool call execution (no specific pattern identified yet). Appears to affect embedded agent runs only, not subagent runs.

Expected Behavior

Tool calls should complete without JSON parse errors in the logging layer.

OpenClaw Version

2026.4.14 (Darwin 25.3.0 arm64)

Logs Available

Full session logs with stack trace available in:

/tmp/openclaw/openclaw-2026-04-21.log

Run IDs affected (28 total):

  • 2e96dc5d-a683-4af5-a2fe-c6a2ac5e9869 (primary)
  • (27 others on same date)

extent analysis

TL;DR

The JSON parse error during embedded agent tool calls may be resolved by inspecting and correcting the JSON serialization of tool call parameters or response context.

Guidance

  • Verify the JSON structure of tool call parameters to ensure it is well-formed and correctly nested, as the error suggests a malformed array element.
  • Investigate the OpenClaw metadata wrapper to determine if it is altering the JSON structure in a way that causes the parse error.
  • Check the logging serialization layer for potential issues with handling JSON data, such as incorrect character encoding or escaping.
  • Review the full session logs, including the stack trace, to gain more insight into the error and its causes.

Example

No specific code snippet can be provided without more information on the tool call parameters or the OpenClaw logging serialization layer. However, a general example of well-formed JSON might look like:

{
  "key": "value",
  "array": [
    "element1",
    "element2"
  ]
}

Ensure that all JSON data follows this structure to prevent parse errors.

Notes

The error's intermittent nature and lack of clear pattern make it challenging to pinpoint the exact cause without further investigation. The fact that tool calls complete successfully despite the error suggests that the issue is isolated to the logging layer.

Recommendation

Apply a workaround by inspecting and correcting the JSON serialization of tool call parameters or response context, as this is the most likely cause of the error. This approach allows for targeted debugging without requiring a full understanding of the underlying system.

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

openclaw - 💡(How to fix) Fix Embedded agent JSON parse error during tool completion (position 1246) [1 participants]