1024MrL's Codex, on opencode-go/muse-spark-1.3-contributor through the
gateway, had every tool_search turned away before it ran ("failed to
parse tool_search arguments: invalid number" over {"limit": 8.0}), and
exec_command the same ("floating point `2000.0`, expected usize").
grok_integral.go's whole-number rewrite (#1431) already fixes exactly
this, but it ran only when the model was Grok's.
Decision (delegated by the owner): the rewrite runs for every model,
not narrowed to Grok. Why:
- The defect is the model's, not a vendor's: Grok (#1431) and muse-spark
(#3152) both write it, and no list of models would stay complete.
- The rewrite changes only a number written with a fraction of zeros and
no exponent, to the same JSON number. Strict parsers break on 8.0
(Codex's serde u64/usize/i32, Go's json into an int), while every
float-typed field takes 8 (serde f64, Go float64, JS). The one visible
difference is a Python client's json.loads giving int 8 for float 8.0,
which any `number` schema allows.
- Strings, keys, other fractions (2.5, 2.50) and exponents (1.0e3) stay
as written, held by integralCases' edges case.
- The reporter ran it end to end on Windows with real Codex 0.163 and
muse-spark: 6 of 7 and 20 of 21 calls refused without it, 0 with it in
two runs (thread, 10-23).
Gemini routes are left as they were: their call arguments are an object
the client decodes itself, and no report shows the shape there.
What changed:
- passthrough installs intTidy on every Responses, Chat and Messages
reply; translate's Request.Grok and grokServed are gone, encoder wraps
every reply in wholeEncoder and render runs wholeResult. grokModel
stays for grok_schema.go.
- crTidy (glm-5.3-flash*'s stitched CR, #4256) now runs before intTidy,
in the stream, the held-tail chain and the drain. With intTidy on every
route, a whole reply it held went from its flush past crArgs, so the
CR cure never saw it (added in this port: the patch's comment gave a
different reason).
- intTidy's flush says a whole reply with no call marker as it came,
without decoding it (added in this port), since every model's whole
reply now reaches it.
- TestOnlyGrokCallsGetIntegers (which held the old scope) became
TestOtherModelsCallsGetCodexIntegers; TestGrokCallsByUpstreamName is
gone; TestToolSearchWholeFloatLimitGivesCodexIntegers is the report's
shape; TestStitchedCRAndWholeFloatsBothGo (added in this port) holds
both cures on a glm-5.3-flash route, whole and streamed. Its whole
case reads the input's fields as written, not through a decode and
encode, which would print 8.0 as 8 and pass on the old code.
Run at this head (rebased on 2c5d9101b, after #2580's held line in
passthrough's write), on mote:
- go test -tags nogui -count=1 -run 'TestWholeNums|TestGrok|
TestOtherModelsCallsGetCodexIntegers|TestToolSearchWholeFloat|
TestStitchedCRAndWholeFloatsBothGo|StitchedCR|TestCRLeavesHealthy|
TestCRDropper|TestPluginStreamLargeReplies|TestQuietWholeReplyStreamed|
TestTextWritten|TestChatStreamCut|TestPassthroughStream|TestNameless'
./internal/gateway: ok (61s).
- go vet -tags nogui ./internal/gateway on darwin, GOOS=linux and
GOOS=windows: clean. gofmt -l: clean.
- At the review tree: the -run family above (without the last three)
with -race -count=2: ok.
- Not run before the push: the whole gateway package and ./... (the
package runs in the background after).
Broken by hand:
- gateway.go, grok_integral.go and ir.go back at origin/main, tests
kept: TestToolSearchWholeFloatLimitGivesCodexIntegers fails "deltas:
limit is 8.0 in {"query":"exa web search","limit":8.0}, want 8";
TestOtherModelsCallsGetCodexIntegers fails "deltas: yield_time_ms is
2500.0 ..., want 2500"; TestStitchedCRAndWholeFloatsBothGo fails in
both subtests ("limit":8.0).
- the rewrite on every route but the old order (ints before crArgs):
TestStitchedCRAndWholeFloatsBothGo/whole, TestChatReplyToolArgsLoseStitchedCR
and TestAnthropicWholeRelayedToolArgsLoseStitchedCR fail with the
stitched \r kept.
Not tried: a real muse-spark or Codex run by this port (the reporter's
runs stand in); a Gemini client. Risk not covered: a vendor that streams
SSE labelled Content-Type application/json. eventStream reads that as a
whole reply, and intTidy, now on every Responses, Chat and Messages
route, holds a whole reply to its flush, so such a stream would reach
the client only at its end, on every route rather than Grok's alone
(crTidy and chatWhole already hold such bodies on theirs). No vendor was
checked for it; a report of a stream arriving all at once points here.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>