Skip to content
Source
Sign inSign up
TanStack/schemas

Probe maxOutput, contextWindow, replay and mandatory on chat/completions, and run it weekly #730

Mergedtombeckenhammerged 3 commits intomain fromfeat/717-probe-more-factsmerged by tombeckenham View on GitHub

tombeckenhamcommented

Probe 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: the ChatCompletionsProbe config, three request bodies (limits, replay, off) and classifyProbeResponse(check, status, body), a pure classifier.
  • ProbedFactRecord in probes/types.ts (the route records stay as they were). Records live in probes/records/<provider>.ts and are written only by pnpm run probe -- <provider> --write.
  • withProbedFacts in probes/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 are probe-verified with verifiedAt: factSources.maxOutput, factSources.contextWindow, factSources.requestMapFields.replayReasoningContent, and a new factSources.reasoningMandatory.
  • staleProbeCount counts the new records too, so GET /v1/status staleProbes covers them.
  • Served shape: ModelFactSources.reasoningMandatory added. openapi.json and the client regenerated, MODEL_ROW_SHAPE 9 to 10, client changeset.
  • .source/workflows/probe.ts: weekly (Mondays 03:17 UTC) plus manual. Runs the probe with --write --skip-missing-key per provider, then, only on a run of main, commits probes/records/ to probe/weekly and opens a pull request only when git status shows a change there. A failing git status fails 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_tokens must be less than or equal to N, the maximum value for max_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 refuses reasoning_content on the assistant turn by name (pydantic extra_forbidden at ...assistant.reasoning_content, Mistral; Groq "property 'reasoning_content' is unsupported").
  • reasoning.mandatory: true: only for a provider that opts in with mandatoryRule: '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) and reasoning_effort is the model's only reasoning control. Without it the off request is not sent at all. It applies only to a row whose stored reasoning mode is effort with mandatory: null, and must pass reasoningViolation. The ModelReasoning doc 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 = 30 per 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.
  • replay and off send max_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 oversized max_tokens of the limits check 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, host api.groq.com, header Authorization: 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)

  1. src/server/providers/probes/<provider>.ts exporting probe: ChatCompletionsProbe (provider, full url, route = the endpoint id rows bind, keyEnv, models, and optionally mandatoryRule under the conditions above; without it each model costs 2 requests, with it 3).
  2. src/server/providers/probes/records/<provider>.ts with export const records: Array<ProbedFactRecord> = [].
  3. In probes/index.ts, add the probe to chatProbes and the records to probedFactRecords.
  4. In .source/workflows/probe.ts, add the id to PROVIDERS, the key to secrets ({ optional: true }) and the API host to egress.
  5. pnpm run probe -- <provider> --write and commit the records it wrote.

Run live

  • pnpm run probe -- groq --write (Groq opts in with mandatoryRule: 'groq'): 6 requests, all decided: maxOutput 65536, replayReasoningContent false and reasoning.mandatory true for openai/gpt-oss-20b and openai/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 rewrites records/groq.ts byte for byte (no new live request). With the key unset and --skip-missing-key it 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).

    1. tombeckenham pushed09d6cb0

    2. tombeckenham merged thisc9a50a4

    3. tombeckenham closed this

Sign in to join this conversation.