Files
coder/coderd
Ethan 6173b0ac28 refactor: stop chatd reading the provider URL for Gemini thinking (#32902)
Relates to WI-97

Since #32849, chatd reads the AI provider's base URL to work out whether
a Gemini request will reach Google. It needs to know, as it swaps
`reasoning_effort` for a `thinking_config` when it will, and Google
rejects a request that carries both, whilst every other upstream needs
`reasoning_effort`. So chatd has to predict what AI Gateway is going to
do with the request, and #32811 takes the base URL away from chatd.

Instead, chatd now sends both fields for a thinking-capable Gemini
model, whatever the provider, and AI Gateway drops `reasoning_effort`
when it forwards a `thinking_config` to Google. It already leaves
`extra_body` out for every other upstream, so those still only get
`reasoning_effort`. chatd also stops stamping thought signatures, as AI
Gateway drops them when it parses the request and stamps its own.

I compared the request body that reaches the upstream on `main` and on
this branch, across 315 combinations of provider, model, effort and
pinned thinking config, and they're identical. The one difference is for
other AI Gateway clients: a request that sends both fields to a Google
provider is no longer rejected with a 400.

I also ran live `gemini-3-flash-preview` chats on `main`, this branch
and the top of the stack, against a provider that points at Google and
one that doesn't, with different efforts, a pinned thinking level, a
pinned budget and a tool call. Every turn finished, and what reached the
upstream was the same on all three, apart from text the model wrote
itself. Google was behind dogfood's AI Gateway, which doesn't serve a
Gemini 2.5 model, so I didn't run one.

I've put this at the bottom of the stack, as it only replaces how #32849
picks the request shape and doesn't depend on anything above it.
2026-12-02 20:59:34 +11:00
..