openclaw - 💡(How to fix) Fix [Bug]: GitHub Copilot provider crashes with SyntaxError when API returns gzip-compressed response [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#81384Fetched 2026-05-14 03:32:48
View on GitHub
Comments
2
Participants
3
Timeline
2
Reactions
1
Timeline (top)
commented ×2

The GitHub Copilot model provider (github-copilot/claude-sonnet-4.6) intermittently crashes all agent sessions with a JSON parse error when the Copilot API returns a gzip-compressed HTTP response. The TUI displays the error as containing an emoji (🔊) because the binary gzip header bytes are rendered garbled.

Error Message

[openai-compat] chat completion failed: SyntaxError: Unexpected token '', "🔊"... is not valid JSON

The raw bytes in the structured log are:

"SyntaxError: Unexpected token '\u001f', \"\u001f\uFFFD\b\u0000\u0000\u0000\u0000\u0000\u0000\u0003\"... is not valid JSON"

Decoded: 0x1F 0x8B 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x03 — this is the standard gzip file header (magic bytes).

Root Cause

The GitHub Copilot API returns Content-Encoding: gzip on larger responses. OpenClaw's HTTP client for the Copilot provider does not decompress the response body before calling JSON.parse(). This causes an immediate crash for any session that produces a response large enough to trigger gzip compression.

Fix Action

Workaround

Switch primary model to Anthropic direct API which doesn't exhibit this issue:

openclaw config set agents.defaults.model.primary anthropic/claude-3-7-sonnet-20250219

Code Example

[openai-compat] chat completion failed: SyntaxError: Unexpected token '', "🔊"... is not valid JSON

---

"SyntaxError: Unexpected token '\u001f', \"\u001f\uFFFD\b\u0000\u0000\u0000\u0000\u0000\u0000\u0003\"... is not valid JSON"

---

2026-05-13T06:20:30.790-04:00 [openai-compat] chat completion failed: SyntaxError: Unexpected token '', "🔊"... is not valid JSON
2026-05-13T06:20:32.187-04:00 [diagnostic] lane task error: lane=main durationMs=312 error="SyntaxError: ..."
2026-05-13T06:20:32.189-04:00 [diagnostic] lane task error: lane=session:agent:main:openai-user:01krge9jzk479awc6x1x5jhgdp durationMs=316 error="SyntaxError: ..."

---

openclaw config set agents.defaults.model.primary anthropic/claude-3-7-sonnet-20250219
RAW_BUFFERClick to expand / collapse

Summary

The GitHub Copilot model provider (github-copilot/claude-sonnet-4.6) intermittently crashes all agent sessions with a JSON parse error when the Copilot API returns a gzip-compressed HTTP response. The TUI displays the error as containing an emoji (🔊) because the binary gzip header bytes are rendered garbled.

Error

[openai-compat] chat completion failed: SyntaxError: Unexpected token '', "🔊"... is not valid JSON

The raw bytes in the structured log are:

"SyntaxError: Unexpected token '\u001f', \"\u001f\uFFFD\b\u0000\u0000\u0000\u0000\u0000\u0000\u0003\"... is not valid JSON"

Decoded: 0x1F 0x8B 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x03 — this is the standard gzip file header (magic bytes).

Root Cause

The GitHub Copilot API returns Content-Encoding: gzip on larger responses. OpenClaw's HTTP client for the Copilot provider does not decompress the response body before calling JSON.parse(). This causes an immediate crash for any session that produces a response large enough to trigger gzip compression.

Impact

  • Affects all active sessions simultaneously (both session:agent:main:main and session:agent:main:openai-user:* sessions)
  • Happens repeatedly / intermittently depending on response size
  • Crash persists until gateway restart AND is reproducible immediately on the next large response
  • Previously misidentified as being caused by WhatsApp or Home Assistant channels (confirmed unrelated)

Reproduction

Use github-copilot/claude-sonnet-4.6 as the primary model and send a request that generates a large response (e.g. long conversation context with tool calls). The Copilot API will compress responses above a size threshold.

Logs

gateway.log repeatedly shows:

2026-05-13T06:20:30.790-04:00 [openai-compat] chat completion failed: SyntaxError: Unexpected token '', "🔊"... is not valid JSON
2026-05-13T06:20:32.187-04:00 [diagnostic] lane task error: lane=main durationMs=312 error="SyntaxError: ..."
2026-05-13T06:20:32.189-04:00 [diagnostic] lane task error: lane=session:agent:main:openai-user:01krge9jzk479awc6x1x5jhgdp durationMs=316 error="SyntaxError: ..."

Workaround

Switch primary model to Anthropic direct API which doesn't exhibit this issue:

openclaw config set agents.defaults.model.primary anthropic/claude-3-7-sonnet-20250219

Related

Similar gzip decompression issue was reported for Google AI Studio in #22704 — the root problem appears to be systemic: the HTTP client doesn't handle Content-Encoding: gzip responses from any provider.

Environment

  • OpenClaw: 2026.5.7 (eeef486)
  • Node.js: 26.0.0
  • macOS: 15.7.7
  • Model: github-copilot/claude-sonnet-4.6 (thinking=medium)
  • Also reproduced on beta 2026.5.12-beta.4

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 [Bug]: GitHub Copilot provider crashes with SyntaxError when API returns gzip-compressed response [2 comments, 3 participants]