fix: identify OpenCode Go requests by session

This commit is contained in:
Bohdan Triapitsyn
2026-09-03 11:49:35 +03:00
parent 76128b615f
commit 85bf0a99de
15 changed files with 55 additions and 8 deletions
@@ -483,6 +483,29 @@ describe('callSmallModel — custom provider config', () => {
});
describe('catalog-based base URL (no config override)', () => {
it('identifies OpenCode Go requests with the owning conversation', async () => {
readConfig.mockReturnValue({});
fetchMock.mockResolvedValue(ok('ok'));
await callSmallModel({
auth: { 'opencode-go': { type: 'api', key: 'go-key' } },
catalog: {
'opencode-go': {
id: 'opencode-go',
api: 'https://opencode.ai/zen/go/v1',
models: { utility: { id: 'utility' } },
},
},
workingDirectory: '/proj',
sessionID: 'ses_conversation',
providerID: 'opencode-go',
modelID: 'utility',
prompt: 'hi',
});
expect(lastCall(fetchMock).init.headers['x-opencode-session']).toBe('ses_conversation');
});
it('uses the catalog api field when no config baseURL is set', async () => {
readConfig.mockReturnValue({});
fetchMock.mockResolvedValue(ok('ok'));