fix(tools): unescape over-escaped quotes in 5 tool descriptors causing invalid JSON in tools/list#444
Open
NavinAgrawal wants to merge 1 commit into
Conversation
…ew_fix_loop/run_agent/run_task descriptors
The tool descriptors for run_swarm (line 221), run_agents (222), review_fix_loop
(223), run_agent (224), and run_task (225) were written with quotes
triple-escaped at the source level. Because they sit inside a Zig
multi-line raw string (\\ prefix per line, contents are literal), each
backslash in the source becomes a literal backslash in the JSON output.
The result was tools/list responses with invalid JSON starting around
byte 12805 (varies by build), producing 'Expecting property name enclosed
in double quotes' errors in any MCP client that parses the response with
a standard JSON parser.
Reproduction (against v0.0.28 binary):
REPO_PATH=$HOME devswarm --mcp <<< <initialize + tools/list>
| python3 -c 'import json,sys; json.loads(sys.stdin.readlines()[1])'
# JSONDecodeError at char ~12805
Fix collapses the over-escaped quote sequences in those five tool
descriptors so the emitted JSON has valid single-backslash-quote
escapes inside string values and unescaped quotes at the structural
level. The other ~30 descriptors that already used correct escaping
are unchanged.
Tested by rebuilding (zig 0.15.2) and running the same initialize +
tools/list flow - JSON parses cleanly, tool count is 38, all previously
broken tools (run_swarm etc.) are listed with valid input schemas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The tool descriptors for
run_swarm,run_agents,review_fix_loop,run_agent, andrun_task(lines 221-225 ofsrc/tools.zig) have quotes over-escaped at the source level. Because they sit inside a Zig multi-line raw string (each line prefixed with\\, contents are literal with no escape processing), each backslash in the source becomes a literal backslash in the JSON output. The result istools/listresponses with invalid JSON starting around byte 12805 (offset varies by build), which any standard JSON parser rejects.Concretely: lines 188-220 use the correct form
\\{"name":"X",...}(literal\\prefix, then plain quotes), but lines 221-225 wrote\\{\"name\":\"X\",...}(extra backslashes before every quote). At runtime, those extra backslashes flow through the raw-string literal unchanged and end up in the emitted JSON, breaking parsing.Repro
On unpatched v0.0.28 (and
mainHEADe768863):Surfaces in real MCP brokers/clients as "upstream unavailable" errors with the same parser message. Observed via mcp-broker fronting multiple upstream MCP servers.
Fix
This PR collapses the over-escaped quote sequences in those five tool descriptors so the emitted JSON has valid single-backslash-quote escapes inside string values and unescaped quotes at the structural level. The other ~30 descriptors that already use the correct escaping are unchanged.
Verification
Rebuilt with Zig 0.15.2 and re-ran the same initialize + tools/list flow:
run_swarm,run_agents,review_fix_loop,run_agent,run_task) listed with valid input schemas{"finder":"haiku","fixer":"opus"}in theper_agent_modelfieldEnd-to-end confirmation via mcp-broker:
Notes
src/main.zigstill says0.0.28; left unchanged so this PR is purely the JSON fix.tools/listJSON-validity test if you point at the right harness.