Bad Unicode in tool result bricks session; /compact also fails with same error

Status Fixed / completed
Maintainer reply None cached
Activity 1 comment · opened Aug 14, 2026 · closed Aug 15, 2026

Bug

A malformed Unicode surrogate pair in a tool result makes the entire session unrecoverable.

Steps to reproduce

  1. Run a tool that returns content with a lone high surrogate (e.g. \uD800\uDBFF) with no matching low surrogate
  2. The session context now contains invalid JSON
  3. Every subsequent API call (including /compact) returns: 400 The request body is not valid JSON: no low surrogate in string

Expected behavior

/compact should sanitize or strip invalid Unicode before sending to the API — it's the escape hatch for broken sessions and should be resilient to this.

Alternatively: a 'hard reset to last N messages' option that truncates context without sending it through the API.

Actual behavior

/compact hits the same API endpoint with the same bad context and fails identically. Session is permanently bricked. Only option is abandoning the window.

Impact

Any tool result that happens to contain malformed Unicode (web scrapes, PDF extracts, file reads from external sources) can silently corrupt the session. There is no recovery path.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗