Repository navigation
fix(l3): an inference test for every kind of upstream - #108
Merged
Merged
Conversation
The inference test only knew how to write an Anthropic or an OpenAI Chat request. The other three protocols returned "an inference test does not support a Chatgpt upstream yet, so nothing was sent", so a ChatGPT account — the one kind of upstream you cannot test any other way — could not be timed at all. The probe request now comes out of the same encoder a forwarded request goes through (`convert::encode`), so there is one answer to "what does a request look like in this format" instead of a hand-written copy that drifts. The ChatGPT account keeps the three differences the Codex backend insists on, the same ones forwarding applies: the path is `/responses`, there is no output limit, and the identity headers say ThinkWatch. Two things fall out of reading the stream with the dialect's own parser (`convert::Reader`) instead of looking for keywords in the bytes: the first token is the first token of that format (the Codex backend sends no Content-Type, so sniffing content types would not have found it), and an error reported inside a 200 stream is now a failed test rather than a silent success. Also: - Models that reason get room to reason. Reasoning tokens are output tokens, so a limit of 8 makes a reasoning model spend everything before it says a word, and the test measures nothing. The price sheet says which models those are; they get 512, everything else stays at 8. - An upstream that takes no output limit has no amount either. The estimate shows an empty limit and an empty cost instead of a number that was made up, and the total goes empty with it. - The error on a result is a `Msg` now, so the app can say it in its own language. It used to be an English sentence that the Chinese UI printed as is. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
The inference test (L3) only built a probe for Anthropic and OpenAI Chat upstreams. Everything else got
an inference test does not support a {protocol} upstream yet, so nothing was sent— including a ChatGPT account, which is the one kind of upstream whose speed you cannot check anywhere else.What changed
convert::encode, new). "What does a request look like in this format" now has one answer instead of a hand-written copy that drifts from what is really sent — that drift is what makes "forwarding works, the test fails" impossible to chase down. Anthropic, OpenAI Chat, OpenAI Responses, Gemini and ChatGPT accounts all get a probe now.{base}/responses,max_output_tokensis refused, and the identity headers are ThinkWatch's own.convert::Reader, new) instead of looking for keywords in the bytes. The first token is the first token of that format — the Codex backend sends its stream with noContent-Type, so nothing that sniffs content types would have found it — and an error reported inside a 200 stream now fails the test instead of passing silently.supports_reasoning), so those get 512 and the rest stay at 8. It is a bound, not an expectation — answering "Hi" uses far less, and the result reports the real usage.Msg, so the app can say it in its own language.CONTROL_API_VERSIONgoes to 11.Tests
tw-gateway/tests/chatgpt.rs: the inference test against the fake Codex backend — request shape (/responses, no output limit, streaming, honest identity), first token timed, usage read from a stream that carries noContent-Type; and a refused run that carries what the backend said.tw-gateway/src/l3.rs: every protocol gets a streaming probe of its own shape, the ChatGPT probe matches the backend's rules, the reasoning headroom rule, and the estimate for an upstream with no limit.tw-dialect/src/convert.rs: encoding a request that has no client behind it, reading the first real token and the usage out of a stream, and an error inside a stream.🤖 Generated with Claude Code