mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#4914
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4132
Author: @Tsury
Created: 10/25/2026
Status: ❌ Closed
Base:
main← Head:fix-4078-quoted-call-values📝 Commits (2)
0411a95serve: a string argument that quotes a tool call or reopens its parameter stays exact (#4078)affadaaserve: only a whole quoted <function=NAME> opener keeps a parameter value open (#4078)📊 Changes
2 files changed (+90 additions, -14 deletions)
View changed files
📝
serve/frontend.py(+33 -14)➕
serve/test_quoted_call_values.py(+57 -0)📄 Description
Problem and result
A string tool argument that quotes a whole tool call, or reopens its own parameter, was cut by the output parser (#4078). Coding agents hit this when they write a parser fixture or a heredoc that contains call markup. The call still looked valid, but its argument was wrong:
<tool_call>…</tool_call>block was cut at the quoted call's</parameter>. The rest became assistant text.</parameter>followed by<parameter=content>(the same parameter name) lost its first part.After this change, these values come back byte for byte. This holds for non-streaming parsing and for streamed tool arguments at any chunk size.
Related discussion
#4078. This is a focused parser fix; no defaults or features change.
Approach
param_endalready treats a</parameter>as part of the value unless the next tag is<parameter=or</function>(#210). Two cases still passed that test. This change adds two narrow rules:</parameter>inside a call that the value itself opens is part of the value. The walk counts<function=against</function>from the start of the value. It accepts a close only when every quoted function is closed.</parameter>followed by<parameter=NAME>for the parameter being read is part of the value. A model does not repeat a parameter name inside one call, so this is a value that quotes its own markup.Callers pass the current parameter name (
call_end,function_end,parse_tool_calland the streaming scanner). The streaming scanner now runsparam_endfrom the start of the value so the balance count sees a quoted opener that an earlier chunk delivered. It runs the walk only when the new text holds a</parameter>, so long values do not rescan on every chunk. A 200 KB streamed value at 4-character chunks took 1.21 s with this change and 1.92 s before it (the before figure includes the old per-chunk scan).Behavior that stays the same: prose between two calls still ends the first call, and a value with a bare
</parameter>that is not followed by a parameter or function tag stays in the value as before (#210).Validation
Passed:
python -m unittest serve.test_quoted_call_values -von this branch (base4b9e05a2), Linux, Python 3.14: 2 tests OK. The new test covers a quoted call, a quoted call at the end of the value, a heredoc and a repeated parameter. Each runs whole, streamed and non-streamed, in chunks of 1, 7 and the full length, plus a check that prose between two calls still ends the first. Before the change, the same test fails.python -m unittest discover -s serve -t . -p 'test_*.py'on this branch: 1037 tests, 1 failure (listed under Failed), 12 skipped.param_endchange plus unrelated local patches. Each case asked the model to copy a literal value into one tool call, then compared the argument bytes. Chat, Chat streaming and streaming Responses (through a Responses-to-Chat converter): before, the quoted-call, repeated-parameter and heredoc cases came back truncated or with the head dropped on every route. After, all three were exact on Chat and Responses. On Chat streaming, the heredoc case had one model copy error; two repeats gave one exact copy and one degenerate reply that hit the token limit (sampling at T=1.0, not the parser). Plain values and values with a bare</parameter>or</function>were exact before and after.Failed:
serve.test_keepawake.KeepAwakeTests.test_service_holds_for_the_whole_request_including_early_closefails on unmodified4b9e05a2in the same environment too.serve.test_responses.NoLeakedSampler.test_server_close_ends_the_samplerpassed in the final run but failed in an earlier run of an earlier revision of this branch. It is timing-dependent in this environment.Not run:
serve/frontend.pyand a new test, no backend code.Limits
</parameter>followed by</function>, with no quoted<function=before it, still ends at that close. Without an opener, the parser cannot tell quoted text from a real end.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.