feat(client): support extra headers from model resolution#1575
feat(client): support extra headers from model resolution#1575RoseSecurity wants to merge 3 commits into
Conversation
- Allow providers to return extra headers from resolve_model callback - Merge resolved headers into request authentication - Handle 'auto' model fallback when resolution fails - Return Copilot-Session-Token from copilot provider
There was a problem hiding this comment.
Important
The multiplier removal breaks the existing Copilot model-selection UI. The provider type annotation and README also need to reflect the new resolve_model return value.
Reviewed changes — Adds support for extra headers returned by provider resolve_model, merges them into chat requests, and makes Copilot's auto model resolution a first-class flow by calling /models/session and forwarding the session token.
lua/CopilotChat/client.lua— Caches the originally requested model, accepts an optional second return value fromresolve_model, falls back to theautomodel config when the resolved model is absent from the local list, and merges resolved headers into the authenticated request headers.lua/CopilotChat/config/providers.lua—resolve_modelnow calls/models/sessionand returnsCopilot-Session-Token;get_modelsstops storingbilling.multiplier.
⚠️ billing.multiplier removal breaks model-selection cost indicators
lua/CopilotChat/init.lua still reads model.multiplier at line 346 and renders xN labels at lines 362-363. Removing multiplier from the copilot provider table means those indicators silently disappear.
Technical details
# `billing.multiplier` removal breaks model-selection cost indicators
## Affected sites
- `lua/CopilotChat/config/providers.lua:658` — removes `multiplier = model.billing and model.billing.multiplier or nil` from the model table built by `get_models`.
- `lua/CopilotChat/init.lua:346` — copies `model.multiplier` into the model picker choices.
- `lua/CopilotChat/init.lua:362-363` — appends `'x' .. tostring(item.multiplier)` to the picker label when present.
## Required outcome
- The Copilot model picker must either continue showing cost multipliers for Copilot models, or the dead code reading/displaying `multiplier` must be removed.
## Suggested approach
- Keep `multiplier` in the copilot provider model table, or
- Remove the `multiplier` field from `lua/CopilotChat/init.lua:338-348` and the `xN` indicator block at `lua/CopilotChat/init.lua:362-364`.
## Open questions for the human
- Was the multiplier intentionally dropped from the UI, or should it remain?⚠️ resolve_model return-value contract is not documented
The provider API now accepts an optional second return value (extra headers), but the LuaCATS annotation at lua/CopilotChat/config/providers.lua:533 and the README example at README.md:455 still declare only a string return. Custom-provider authors won't know they can return headers.
Technical details
# `resolve_model` return-value contract is not documented
## Affected sites
- `lua/CopilotChat/config/providers.lua:533` — current annotation: `---@field resolve_model nil|fun(headers:table, model: string):string`
- `README.md:455` — current example: `resolve_model?(headers: table, model: string): string,`
## Required outcome
- Type signature and README example should document the optional headers table return.
## Suggested approach
- Update the LuaCATS annotation to something like `---@field resolve_model nil|fun(headers:table, model: string):string, table<string, string>?`.
- Update `README.md:455` to `resolve_model?(headers: table, model: string): string, table<string, string>?`.
- `doc/CopilotChat.txt` will be regenerated from the README by CI and should not be edited manually.Kimi K2 (free via Pullfrog for OSS) | 𝕏
Update provider config to allow resolve_model to return model id and lookup table. Add model multiplier mapping for Copilot provider and align README type definitions.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the follow-up commit addresses the two concerns from the previous review and makes a formatting-only update to the workflow file.
- Restored
billing.multiplierinlua/CopilotChat/config/providers.luaso the Copilot model picker keeps showing cost multipliers. - Documented the extra headers return value in the provider LuaCATS annotation and README
resolve_modelexample. - Reformatted
.github/workflows/pullfrog.ymlspacing with no semantic change.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
is it just me or the tools call (e.g. |
The |
Tool Usage but now it just does this, like it's unable to call the tool: |



what and why
I woke up this morning to my
:CopilotChatCommitsfailing. I read some docs, added support for Copilot's auto model session flow, and fired up a new session and this code worked for me.Allegedly, GitHub now uses Copilot auto model selection as the default and only model selection experience for Free and Student plans. Instead of assuming that
automaps to a known static model, this PR updates the Copilot provider to resolveautothrough the/models/sessionendpoint and pass the returnedCopilot-Session-Tokenalong with the chat request.autoresolves to a model that is not present in the local model list by reusing theautomodel config with the resolved model id.Copilot auto model selection is now a first-class flow, especially for Free and Student users. Supporting the session token returned by Copilot's auto model endpoint keeps requests aligned with GitHub's current model routing behavior instead of treating
autolike a normal static model alias.