mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4630] [Engine] An array or object tool parameter with a raw newline inside a string reaches the client as a string #2099
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2099
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Efs-O on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4630
Area
[Engine] (speed, kernels, models, the server and API)
Desktop app, Terminal or source?
Desktop app (Windows, Linux or Mac)
What happened
A tool call whose array or object parameter holds multi-line text reaches the client as a string instead of the array or object, and the client rejects the call.
In the Qwen XML form (
<parameter=edits>…</parameter>) the model writes the value as raw text. For a parameter whose declared type is notstring, the parser runsjson.loads(value)and, when that raises, silently passes the raw text through as a string:parse_tool_call,serve/frontend.py:931-935on main46c152a1rawstate,serve/frontend.py:1274-1277The model typically writes a line break inside a JSON string as a real newline, not as
\n. That is natural in this format and is what an agent editing a Markdown file or source code does. Python's defaultjson.loads(strict=True) refuses a raw control character inside a string, so the whole value falls back to a string:The value itself was a correct array of
{"old_str", "new_str"}objects.json.loads(value, strict=False)parses it into exactly that array.Seen with Forge (VS Code agent) as the client, on an
edit_filecall whoseeditsparameter is declared as an array. The client answerededits arrived as a string, not an array and is not valid JSON. The model recovered by switching to a flat single-edit form, but it costs a round each time, and it happens often on long agent sessions that edit Markdown.Expected: a raw newline or tab inside a string in a non-
stringparameter parses as part of that string.Suggested fix:
json.loads(value, strict=False)at both sites. Valid JSON parses exactly as before. The only change is that raw control characters inside strings are accepted, which is what the XML parameter format produces. A parameter that is still not JSON keeps today's fallback.Smallest steps or command that reproduce it
Feeding
parse_tool_calla<tool_call><function=edit_file><parameter=edits>block with that value and a schema declaringeditsasarrayreturnsarguments["edits"]asstr.Reproduction status
Reproduced locally
Strata version
engine 0.1.52 (the code paths above checked on main
46c152a1)Graphics card, memory and system
2x RTX 5060 Ti 16 GB + RTX 3060 12 GB, Windows 10 Pro
Model, size and settings
Qwen3.8-Flash-Next IQ2_XS, 400K context. The model is not the cause: the parameter value it wrote was correct JSON apart from the raw newlines.
@LagutArt commented on GitHub (Oct 30, 2026):
[RU]
Добавлю от себя небольшое наблюдение.
Если аргумент в
propertiesуказан как"type": "string", то сервер возвращает экранированный Unicode. Если аргумент указан как"type":"array","items":{"type":"string"}}то возвращаются Unicode строки.Что забавно сама модель генерирует именно Unicode. И это видно в её последнем ответе.
[EN] (Yandex Translate)
I’ll add a small observation of my own.
If the argument in
propertiesis specified as"type": "string", the server returns escaped Unicode. If the argument is specified as"type":"array","items":{"type":"string"}}, then Unicode strings are returned.What’s funny is that the model itself generates Unicode. And this is evident in its last response.