Skip to content

Escape Unicode separators in JSON-RPC lines - #1671

Open
georgecollier-nqu wants to merge 2 commits into
get-bb:mainfrom
georgecollier-nqu:fix/json-rpc-line-separators
Open

Escape Unicode separators in JSON-RPC lines#1671
georgecollier-nqu wants to merge 2 commits into
get-bb:mainfrom
georgecollier-nqu:fix/json-rpc-line-separators

Conversation

@georgecollier-nqu

@georgecollier-nqu georgecollier-nqu commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Current failure

BB uses one JSON object per line between the host daemon and each provider bridge.

Injected instructions can contain U+2028 or U+2029. These are valid Unicode line separator characters.

  1. JSON.stringify leaves each character literal inside the JSON string.
  2. Node readline treats each character as the end of a line.
  3. A thread/start request becomes two incomplete lines before the bridge parses it.
  4. The bridge catches each JSON.parse failure and returns without a response.
  5. The host waits until thread/start times out. Claude never starts.
  6. The user can remain on Preparing workspace without a useful error.

This failure occurs before BB starts Claude. It is a BB message framing bug, not a Claude Code failure.

Why BB must fix this

The input text is valid and must remain valid. It can come from these sources:

  • AGENTS.md
  • skills
  • system instructions
  • prompts
  • tool schemas
  • provider messages

Sanitizing each source would be fragile and could change user text. The JSON-RPC framing layer owns this requirement.

Escaping these characters keeps each message on one physical line. JSON.parse restores the original Unicode text at the receiver.

Fix

  • Escape U+2028 and U+2029 before BB writes line-delimited JSON-RPC.
  • Apply the fix to runtime-to-bridge messages.
  • Apply the fix to bridge-to-runtime messages.
  • Add regression tests that pass both characters through Node readline.

Validation

  • pnpm exec vitest run src/runtime-json-rpc.test.ts --config vitest.config.ts
  • pnpm exec turbo run typecheck --filter=@bb/agent-runtime

AGENT GENERATED: by GPT-5.6 Sol

@georgecollier-nqu
georgecollier-nqu marked this pull request as ready for review August 16, 2026 20:33
@georgecollier-nqu

Copy link
Copy Markdown
Contributor Author

reviewed manually too

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.

1 participant