Repository navigation
Conversation
|
Thanks. Cutting a serde pass is welcome, but this regresses paid Zen-key requests:
To move forward:
With the gate in place I'd be glad to look again. Please include the byte-identical comparison for a paid model, both streaming and non-streaming. |
PrepareRouteBodies applies the anonymous agent-shape (stream + usage + core tools) to the decoded Zen payload before the single per-tier marshal; the anonymous lane sends bodies[zen] verbatim, deleting its unmarshal+remarshal pass. prepareAnonymousBody stays for probes and the Go-tier key path as a thin wrapper over the same map function. Paid Zen bodies are never shaped: the block is gated on IsFreeModel(route.ID), the same check shapeKeyBody uses, so paid requests keep their exact client shape and the Shaped collapse flag stays consistent. Go and System One paths unchanged.
cb69098 to
6fcbe8f
Compare
|
Revised per feedback:
Paid-model check: with the gate, a paid Zen payload (streaming and non-streaming) passes through byte-identical with no tools injected — verified locally. Free-model output is byte-identical to the old path on stream/non-stream x tools/no-tools payloads plus System One passthrough. |
…114514#79 feedback) Paid Zen bodies must be left alone; shaping is a free-tier requirement. Without the IsFreeModel gate a paid request would get stream/tools forced while shapeKeyBody reports unshaped, so a non-streaming paid client would receive raw SSE instead of JSON.
|
Thanks — the paid-model regression was a real miss on my part, and the revision (gating on One update worth having: v1.4.1 ( I don't think there's a perf argument left that upstream's per-lane shaping doesn't already cover, so feel free to close this rather than reviewing it further. If you'd rather keep the map-level helper for the key tiers, say so and I'll rebase it onto v1.4.1 and re-run the paid byte-equivalence proof — otherwise I'll close it from my side. For the record on what I'd keep from this thread either way: the |
Every request pays 2-3 full JSON serde passes: prepareRouteBodies marshals per tier, then the anonymous lane unmarshals the Zen body back into a map, forces stream+usage+tools, and remarshals. The key lane repeats the unmarshal for its shaped comparison.
This shapes the Zen payload on the decoded map before the single per-tier marshal, so the anonymous lane sends bodies[zen] verbatim. prepareAnonymousBody stays for probes and the Go-tier key path as a thin wrapper over the same map function, so one source of truth. shapeKeyBody on Zen reports shaped structurally (Zen bodies always arrive pre-shaped; collapse only serves non-streaming clients whose payloads always needed forcing, so the old compare was always true everywhere it is read). Go and System One paths unchanged.
Validation: go vet clean, go build -trimpath clean, gofmt clean. Verified byte-identical output on stream/non-stream x tools/no-tools payloads plus System One passthrough against the old path.