fix(small-model): route anthropic provider through configured baseURL

The Anthropic small-model dispatch (session-assist recap/suggestion,
walkthrough, etc.) hardcoded https://api.anthropic.com/v1/messages,
ignoring provider.anthropic.options.baseURL — the same override every
other provider branch already respects. Any setup routing the anthropic
provider through a local proxy (e.g. Meridian for Claude Max / Vertex)
had the small-model call bypass the proxy and hit the real Anthropic API
with whatever placeholder credential the proxy config uses, failing with
401 invalid x-api-key on every call.
This commit is contained in:
Matt Peter
2026-08-25 09:42:28 -04:00
parent 3b7d5e1c34
commit f459206e4a
3 changed files with 49 additions and 3 deletions
+1
View File
@@ -64,6 +64,7 @@ All notable changes to this project will be documented in this file.
- Git: pull-request checks in Work status stay current as their status changes.
- UI: the default dialog close button is easier to click or tap (thanks to @rockinrimmer).
- Desktop/Windows: the close button now aligns correctly with the rest of the window chrome.
- Session assist: recaps and suggested follow-ups now work when the Anthropic provider is configured to use a custom endpoint; they previously failed every time instead of using that configured connection.
## [1.19.0] - 2026-08-19
+3 -3
View File
@@ -340,8 +340,8 @@ const callMessages = async ({ url, headers, modelID, prompt, system, maxOutputTo
return text;
};
const callAnthropic = async ({ apiKey, modelID, prompt, system, maxOutputTokens, responseSchema, timeoutMs, signal }) => callMessages({
url: 'https://api.anthropic.com/v1/messages',
const callAnthropic = async ({ apiKey, baseURL, modelID, prompt, system, maxOutputTokens, responseSchema, timeoutMs, signal }) => callMessages({
url: `${(baseURL || 'https://api.anthropic.com').replace(/\/+$/, '')}/v1/messages`,
headers: {
'x-api-key': apiKey,
'anthropic-version': '2023-06-01',
@@ -706,7 +706,7 @@ export async function callSmallModel({ auth, catalog, workingDirectory, provider
}
if (providerID === 'anthropic') {
return callAnthropic({ apiKey, modelID, prompt, system, maxOutputTokens: tokens, responseSchema, timeoutMs, signal });
return callAnthropic({ apiKey, baseURL: providerConfig?.baseURL, modelID, prompt, system, maxOutputTokens: tokens, responseSchema, timeoutMs, signal });
}
if (providerID === 'google') {
return callGoogle({ apiKey, modelID, prompt, system, maxOutputTokens: tokens, responseSchema, timeoutMs, signal });
@@ -316,6 +316,51 @@ describe('callSmallModel — custom provider config', () => {
});
});
describe('anthropic provider custom baseURL override', () => {
const anthropicOk = (text) => ({
ok: true,
status: 200,
json: async () => ({ content: [{ type: 'text', text }] }),
});
it('respects provider.anthropic.options.baseURL over the hardcoded Anthropic endpoint', async () => {
readConfig.mockReturnValue({
provider: { anthropic: { options: { baseURL: 'http://127.0.0.1:3456' } } },
});
fetchMock.mockResolvedValue(anthropicOk('ok'));
await callSmallModel({
auth: { anthropic: { type: 'api', key: 'dummy' } },
catalog: {},
workingDirectory: '/proj',
providerID: 'anthropic',
modelID: 'claude-haiku-4-5',
prompt: 'hi',
});
const { url, init } = lastCall(fetchMock);
expect(url).toBe('http://127.0.0.1:3456/v1/messages');
expect(url).not.toContain('api.anthropic.com');
expect(init.headers['x-api-key']).toBe('dummy');
});
it('falls back to https://api.anthropic.com when no anthropic baseURL override is configured', async () => {
readConfig.mockReturnValue({});
fetchMock.mockResolvedValue(anthropicOk('ok'));
await callSmallModel({
auth: { anthropic: { type: 'api', key: 'sk-ant' } },
catalog: {},
workingDirectory: '/proj',
providerID: 'anthropic',
modelID: 'claude-haiku-4-5',
prompt: 'hi',
});
expect(lastCall(fetchMock).url).toBe('https://api.anthropic.com/v1/messages');
});
});
describe('catalog-based base URL (no config override)', () => {
it('uses the catalog api field when no config baseURL is set', async () => {
readConfig.mockReturnValue({});