Skip to content

fix: handle escape sequences#894

Open
vvaswani wants to merge 1 commit intoanthropics:mainfrom
vvaswani:882-escape-sequences
Open

fix: handle escape sequences#894
vvaswani wants to merge 1 commit intoanthropics:mainfrom
vvaswani:882-escape-sequences

Conversation

@vvaswani
Copy link

Fixes #882

@vvaswani vvaswani requested a review from a team as a code owner January 30, 2026 20:49
Signed-off-by: Vikram Vaswani <2571660+vvaswani@users.noreply.github.com>
@vvaswani vvaswani force-pushed the 882-escape-sequences branch from f3cd353 to d80864e Compare February 18, 2026 18:20
@MaxwellCalkin
Copy link

I ran into this same issue when testing MCP tool results containing Unicode line separators. Confirmed this fix is correct — JSON.stringify does not escape U+2028/U+2029, but Node's readline treats them as line terminators, splitting the JSON output mid-line.

Verified that the only call site needing the fix is toReadableStream() in src/core/streaming.ts. The replacement approach here (post-stringify escaping to \u2028/\u2029) is clean and round-trips correctly through JSON.parse.

Also tested U+0085 (NEL) — Node's readline does NOT treat it as a line separator, so no additional escaping is needed. This PR's scope is correct.

Would be great to get this merged — it's been open since January 30 and the fix is minimal (5 lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

U+2028 LINE SEPARATOR in MCP tool results causes JSON parsing failures.

2 participants