mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5226] [Engine] tool-call serializer wraps string parameter values in literal backslash-n escapes #3112
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#3112
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 @sauris on GitHub (Nov 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5226
Area: [Engine] (speed, kernels, models, the server and API)
Desktop app, Terminal or source? Desktop app (Windows)
Strata version: Strata 0.2.10 · engine 0.1.56 (windows-x86_64-hip-rx9070)
Graphics card, memory and system: AMD Radeon AI PRO R9700 32 GB · 128 GB RAM · Windows 11
Model, size and settings: Qwen3.8-Flash-Next IQ3_S (GSQ-RCO) · 128K context · pictures on ·
--spec 4 --spec-min-p 0.5 --kv int8 --kv-resident 32768What happened:
A tool call's string parameter value arrives wrapped in literal
\nescape sequences:Expected:
"path": "notes/weather-log.md".Actual:
"path": "\nnotes/weather-log.md\n"(literal backslash-n escapes inside the JSON string). The arguments JSON itself parses fine, so strict clients pass the corrupted value straight through and downstream file operations fail on the path.Characteristics: intermittent — 4 of 30 scripted two-tool requests at
temperature: 0; so far always on the second tool call of a reply, never the first. Persists unchanged withSTRATA_ROUTE_TAIL_SKIP=0(speculative-verify hardening doesn't touch it), which points at the tool-call capture/serialization path — likely the template whitespace around the value being captured into the string and then JSON-escaped. Same area as the call-format parsing fixed in PR #3960.Smallest steps or command that reproduce it:
Scripted probe:
POST /v1/chat/completions, two function tools (second one takes a plain string path parameter),temperature: 0, repeated ~15 times with identical payloads → the\n-wrapped value appears in roughly every third reply that includes the second call. Stdlib-python probe script available.Reproduction status: Reproduced locally (4/30 across two independent sessions, engine restarted between them).
Full
strata-iq3_s.logexcerpts available on request (sanitized).@github-actions[bot] commented on GitHub (Nov 4, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@github-actions[bot] commented on GitHub (Nov 4, 2026):
Thanks, this follows the format now.
@udqe commented on GitHub (Nov 5, 2026):
Ran your probe shape on the CUDA side of the same serve layer, Windows 11, engine 0.1.56
windows-x86_64-cuda-cuda13, production pair under a layer split. Result is a negative box with an honest effective-n story, plus two structural notes that survive the negative.v1, 30 identical requests,
temperature 0, your two-tool shape: all 30 replies carried ONE call - this model+template pair serializes the calls instead of emitting both up front - so on the pattern you describe (always the second call of a reply) the effective n was zero, and I am saying that before any conclusion. What v1 does show: the 30 single-call argument values were all clean.v2, protocol extended before running, 12 requests with the reply forced to carry both calls ("issue BOTH calls in the same reply, before any results"): 12/12 replies carried two calls, all 12 clean, no wrapped
\non either call. Against your observed 4/30 that is P(0 of 12) = 19 % - a clean 12 at your rate is not rare, so this is a weak negative, not a disproof, and it is adopted as such by the pre-declared rule.The interesting part of being a negative: my box never crossed the boundary you suspect. Our model emits the second call at a position the capture path reads cleanly, so the situation where unexpected template whitespace rides into the value simply does not occur here - absence of the trigger, not a clearance of the parser. That is consistent with your characteristics being model-shaped: intermittent at T=0, always the second call, and (as far as we know) one mixed-quant model so far. If a maintainer wants the boundary exercised, a second model per box will do more than a second box.
Two facts from the shipped tree (main at 2026-11-03) for whoever fixes it. First, the serve layer passes the parser's argument string through without touching it - non-stream
server.py:6619putsc.argumentsstraight into the reply, streamed deltas at:6845-6852likewise - so there is no later stage that could trim a value with stray leading/trailing whitespace; wherever the capture happens, it owns the bug end to end. Second, the shipped sanity suite's tool cases are single-call only (lookup_record,get_weather,convert_units,get_build_statusin the bench outputs - all one call per reply): there is no two-call case in what ships, which is the same blind spot as your "always the second call", and a guarded two-call probe in that suite is where I would want the regression test.Offer, same as I have meant elsewhere on this tracker: post your probe's exact request body (or a gist of the script) and we will run it byte-identical on this CUDA boot - second vendor, same OS family, same engine version; our quant and spec settings differ, and I will report exactly that when it comes back.
Scope box: this is a production box with a declared-before-data protocol (run files kept; the v1 effective-n disclosure above is part of that), UD-Q4_K_XL where your IQ3_S is the model we do not run, and I am a user, not a maintainer.
(ai-assisted; protocol+log: two runs, 30+12 requests, declared 10:55/10:58 JST before each arm)
@sauris commented on GitHub (Nov 5, 2026):
Update after upgrading to Strata 0.2.11 / engine 0.1.57: still present.
Stock defaults (
ROUTE_TAIL_SKIP=7 is ON): the identical wrapped-form corruption appeared in 1 of 17 scripted requests (temperature 0):With
STRATA_ROUTE_TAIL_SKIP=0: 0 of 25 showed the wrapped form, but one reply had a trailing-space value instead ("notes/weather-log.md ") — same whitespace-in-string-parameter family, milder form.So the serializer bug survives 0.1.57 in both its wrapped and trailing-whitespace forms.
@sauris commented on GitHub (Nov 5, 2026):
Thanks @udqe — this is a clean pair of runs, and the effective-n disclosure is exactly how I'd want a negative reported. Two things from your shipped-tree reading resolve the "where" question better than my original report did:
Agreed on the capture path. If the serve layer passes
c.argumentsthrough untouched (both the non-stream and delta paths), then the\nescapes were already in the string when it left the capture stage — the capture owns the bug end to end. That also fits my milder variant: withSTRATA_ROUTE_TAIL_SKIP=0I stopped seeing wrapped values and saw a trailing-space value once ("notes/weather-log.md ") — whitespace riding in at capture, later JSON-escaped.The second-call position is likely the trigger boundary. My reply shape always has the model emit both calls in one assistant turn (I request both actions in one user turn, no results in between — same situation your v2 forced), and every observed artifact was on the second call, never the first. Your box never crosses that boundary because your pair serializes the calls, so your negative is exactly what your model-shaped hypothesis predicts.
Adding two datapoints since the report: on engine 0.1.57 / app 0.2.11 the wrapped form still fired once in 17 stock requests, and with the skip workaround off I saw the trailing-space variant once in 25 — so the capture artifact survives 0.1.57 in both forms.
Exact request body (the payload my probe sends;
HERMES_CUSTOM_STRATA_API_KEYauth, non-stream):Probe script (stdlib-only python; loops the payload, checks each
argumentsfor parse failures and embedded whitespace, and assembles streamed deltas the same way): https://gist.github.com/sauris/456177b4e2c175e1c0dca2011610e447If you run it byte-identical, the one thing to watch is whether your pair ever emits both calls up front under this exact body — if it serializes them again, your v2 forcing shape is the only way to cross the boundary, and then the second call's
pathvalue is the thing to diff against the model's raw output. Fully agree the guarded two-call probe belongs in the shipped sanity suite — the current single-call cases can't see this boundary at all.@udqe commented on GitHub (Nov 6, 2026):
v3 follow-up on my earlier negative in this thread - now with the boundary crossed at force: 60 replies, zero artifacts, and an upgrade to the platform hypothesis.
What changed since my v2. Two batches (20 + 40 requests,
temperature 0,max_tokens 512, unique salt per request so nothing replays from cache) using exactly the shape your probe needs: two function tools in the request, the reply forced to carry BOTH calls before any results (get_time, thenread_notewith a plain stringpath), the path presented fenced-with-newlines around it so the whitespace your capture suspects is sitting right at the value boundary in the template. 60 of 60 replies carried two tool calls - the second-call position was crossed every single time, which was the whole weakness of my v2 (your model emits both; mine serialized, so the effective boundary count was zero).Result: all 60 second-call arguments are exactly
{"path":"notes/weather-log.md"}. Zero wrapped forms, zero trailing-space variants (I checked that family separately since yourROUTE_TAIL_SKIP=0datapoint says it is the same seam), zero other deviations. Cumulative binomial against your observed rate (about 13% of second calls): P(0 of 60) = 0.87^60 = 0.02%. Not a disproof in principle, but the "it exists here and I got lucky 60 times" reading is now off the table.What this does and does not say. Your capture-ownership analysis survives - the serve layer really does pass
argumentsthrough untouched on both paths, and both artifact forms are capture-side. What no longer fits is a platform-independent capture bug: same serve layer, same capture, and the trigger fires on your pair of machines and never across 60 forced crossings here. The asymmetries left are the ones neither arm has varied: your engine is the HIP build (0.1.56 and 0.1.57, windows-x86_64-hip-rx9070) and your pack is IQ3_S GSQ-RCO; mine is CUDA cuda13 with UD-Q4_K_XL. Something in {HIP build, IQ3_S GSQ pack, this template pair} is load-bearing for the artifact.The decisive cell, cheap to run for anyone with the parts: the IQ3_S GSQ-RCO pack on a Windows CUDA engine - pack swapped, platform fixed. Reproduces there, it is pack/template-side; stays silent there, it is HIP-side, and then a second 4090-class box running your exact server line would close it. Protocol above is complete enough to copy verbatim; the artifact needs no special values, just the double-call forced shape and the fenced path.
Numbers: batches n=20 and n=40, all forced-double-call, all clean, CUDA engine 0.1.57, UD-Q4_K_XL, layer-split 2x4090,
--spec 4. Happy to paste the raw per-request argument dump.