fix(coding-agent): allow headers-only model overrides closes #3538

This commit is contained in:
Mario Zechner
2026-04-22 13:25:45 +02:00
parent 049e320570
commit b4f9b618d3
3 changed files with 26 additions and 3 deletions

View File

@@ -13,6 +13,7 @@
### Fixed
- Fixed extension session-replacement flows so `ctx.newSession()`, `ctx.fork()`, `ctx.switchSession()`, and imported-session replacements fully rebind before post-switch work runs, added `withSession` replacement callbacks with fresh `ReplacedSessionContext` helpers, and make stale pre-replacement `pi` / `ctx` session-bound accesses throw instead of silently targeting the wrong session ([#2860](https://github.com/badlogic/pi-mono/issues/2860))
- Fixed `models.json` built-in provider overrides to accept `headers` without requiring `baseUrl`, so request-header-only overrides now load and apply correctly ([#3538](https://github.com/badlogic/pi-mono/issues/3538))
## [0.68.1] - 2026-04-22

View File

@@ -474,10 +474,10 @@ export class ModelRegistry {
providerConfig.modelOverrides && Object.keys(providerConfig.modelOverrides).length > 0;
if (models.length === 0) {
// Override-only config: needs baseUrl, compat, modelOverrides, or some combination.
if (!providerConfig.baseUrl && !providerConfig.compat && !hasModelOverrides) {
// Override-only config: needs baseUrl, headers, compat, modelOverrides, or some combination.
if (!providerConfig.baseUrl && !providerConfig.headers && !providerConfig.compat && !hasModelOverrides) {
throw new Error(
`Provider ${providerName}: must specify "baseUrl", "compat", "modelOverrides", or "models".`,
`Provider ${providerName}: must specify "baseUrl", "headers", "compat", "modelOverrides", or "models".`,
);
}
} else if (!isBuiltIn) {

View File

@@ -135,6 +135,28 @@ describe("ModelRegistry", () => {
}
});
test("headers-only override resolves at request time", async () => {
writeRawModelsJson({
anthropic: {
headers: {
"X-Custom-Header": "custom-value",
},
},
});
const registry = ModelRegistry.create(authStorage, modelsJsonPath);
expect(registry.getError()).toBeUndefined();
const anthropicModels = getModelsForProvider(registry, "anthropic");
for (const model of anthropicModels) {
const auth = await registry.getApiKeyAndHeaders(model);
expect(auth.ok).toBe(true);
if (auth.ok) {
expect(auth.headers?.["X-Custom-Header"]).toBe("custom-value");
}
}
});
test("baseUrl-only override does not affect other providers", () => {
writeRawModelsJson({
anthropic: overrideConfig("https://my-proxy.example.com/v1"),