Probe maxOutput, contextWindow, replay and mandatory on chat/completions, and run it weekly #730
main fromfeat/717-probe-more-facts·merged by tombeckenham View on GitHubProbe records can now state maxOutput, contextWindow, replayReasoningContent and reasoning.mandatory, from one generic probe for the chat/completions wire. A weekly Source CI job runs it and opens a pull request when a record changed.
What changed#
src/server/providers/probes/chat-completions.ts: theChatCompletionsProbeconfig, three request bodies (limits,replay,off) andclassifyProbeResponse(check, status, body), a pure classifier.ProbedFactRecordinprobes/types.ts(the route records stay as they were). Records live inprobes/records/<provider>.tsand are written only bypnpm run probe -- <provider> --write.withProbedFactsinprobes/index.ts, called from the poller: it fills a row's empty fact from a record naming that exact model and the route the row binds. It never replaces a stated value. Sources areprobe-verifiedwithverifiedAt:factSources.maxOutput,factSources.contextWindow,factSources.requestMapFields.replayReasoningContent, and a newfactSources.reasoningMandatory.staleProbeCountcounts the new records too, soGET /v1/statusstaleProbescovers them.- Served shape:
ModelFactSources.reasoningMandatoryadded.openapi.jsonand the client regenerated,MODEL_ROW_SHAPE9 to 10, client changeset. .source/workflows/probe.ts: weekly (Mondays 03:17 UTC) plus manual. Runs the probe with--write --skip-missing-keyper provider, then, only on a run ofmain, commitsprobes/records/toprobe/weeklyand opens a pull request only whengit statusshows a change there. A failinggit statusfails the job. It never merges.- Groq opted in (
probes/groq.ts, two gpt-oss models) with a live record file.
Evidence rules#
A value is stored only from a 400 or 422 whose error message matches a rule taken from a real captured body:
maxOutput: OpenAI "This model supports at most N completion tokens"; Groq "max_tokensmust be less than or equal toN, the maximum value formax_tokens...".contextWindow: in the record type (the issue's widening), but no rule writes it yet: no live response stated one, and every rule must come from a real response.replayReasoningContent: false: the provider refusesreasoning_contenton the assistant turn by name (pydanticextra_forbiddenat...assistant.reasoning_content, Mistral; Groq "property 'reasoning_content' is unsupported").reasoning.mandatory: true: only for a provider that opts in withmandatoryRule: 'groq' | 'openai', and only in that provider's own wording:reasoning_effort: "none"refused with the model's own level list and no off value in it (OpenAI "does not support 'none' with this model. Supported values are: ..."; Groq "must be one of ..."). Set the opt-in only when the provider's level list is per model (not one enum shared by all models, nor a gateway forwarding an upstream 400) andreasoning_effortis the model's only reasoning control. Without it theoffrequest is not sent at all. It applies only to a row whose stored reasoning mode iseffortwithmandatory: null, and must passreasoningViolation. TheModelReasoningdoc now says a bare 400 is still not a source, and a probe record is one only when that field is the model's only reasoning control.
Everything else records nothing and the run prints why: any 2xx, timeout or network error, 401/403, 402, 404, 429, 5xx, and any 400/422 no rule reads. Fireworks "Max tokens must not exceed 1048576" is one such: that number is the model's context window, so it is not read as maxOutput. The fixtures (27 real bodies from 2026-11-21, account ids and a masked key fragment replaced) include all of these.
An undecided check keeps the stored record and the run prints stored record not reconfirmed: <model> <fact>. mergeProbedRecords reads only the running provider's records, so two providers probing the same model id never cross. A decided check with the same value re-dates the record only after 60 days, so a weekly run with nothing new changes no file and opens no pull request.
Spend cap and keys#
MAX_PROBE_REQUESTS = 30per provider run. A run that plans more (models x 3 checks) exits 1 before the first request, and the send loop throws if the count is ever passed.replayandoffsendmax_tokens: 1. Every body streams and a 2xx body is cancelled unread. Cancelling does not guarantee the provider stops billing; the real bound on the oversizedmax_tokensof thelimitscheck is the one-word prompt. 30 second timeout per request.- The key goes only in the Authorization header. A failed fetch reports only that it failed. Auth error bodies are never printed (Sambanova echoes a masked key). Printed and stored messages have the key replaced.
Secrets the maintainer must add#
None set by this PR. For the weekly job, in the development CI environment:
GROQ_API_KEY, hostapi.groq.com, headerAuthorization:src secret set GROQ_API_KEY --env development --host api.groq.com --header Authorization < groq-key.txt
Without it the job prints skip groq: GROQ_API_KEY is not set and passes. pulls: 'create' works only in a protected run, so the schedule needs the main branch rule that requires a pull request.
How a provider opts in (#716)#
src/server/providers/probes/<provider>.tsexportingprobe: ChatCompletionsProbe(provider, fullurl,route= the endpoint id rows bind,keyEnv,models, and optionallymandatoryRuleunder the conditions above; without it each model costs 2 requests, with it 3).src/server/providers/probes/records/<provider>.tswithexport const records: Array<ProbedFactRecord> = [].- In
probes/index.ts, add the probe tochatProbesand the records toprobedFactRecords. - In
.source/workflows/probe.ts, add the id toPROVIDERS, the key tosecrets({ optional: true }) and the API host toegress. pnpm run probe -- <provider> --writeand commit the records it wrote.
Run live#
pnpm run probe -- groq --write(Groq opts in withmandatoryRule: 'groq'): 6 requests, all decided:maxOutput65536,replayReasoningContentfalse andreasoning.mandatorytrue foropenai/gpt-oss-20bandopenai/gpt-oss-safeguard-20b. Committed as written. A second run left the file unchanged. After the review fixes, re-classifying the committed evidence and merging as the script does rewritesrecords/groq.tsbyte for byte (no new live request). With the key unset and--skip-missing-keyit printed the skip and exited 0.- Fixture capture across OpenAI, Groq, Mistral, Fireworks, Together, xAI, Gemini, Moonshot, Novita, Cerebras, DeepSeek, Hyperbolic, Sambanova and Baseten (about 25 requests).
Not run: the Source workflow itself (src ci plan loads it; it has not run on the forge). No rule writes contextWindow yet.
Checks#
pnpm run typecheck, pnpm run lint, pnpm run check, pnpm run check:client and pnpm run test (259 files, 2612 tests) pass, after merging main (MODEL_ROW_SHAPE is now 11: main took 10 for aliasOf).