allow proxy auto model selection
CI / 1. BUILD (pull_request) Successful in 2s
CI / 2. TEST (pull_request) Successful in 2s
CI / 3. RESULT (pull_request) Successful in 0s

This commit is contained in:
2026-08-07 06:16:45 +00:00
parent 0eb30cf9d4
commit 651e221e90
10 changed files with 96 additions and 41 deletions
+20 -1
View File
@@ -4,7 +4,7 @@ import axios from 'axios';
import { extractBalancedJSON, extractJSONText, extractMeaningfulError, mapWithConcurrency } from '../llm.js';
const ENV_KEYS = [
'CLI_PROXY_API', 'CLI_PROXY_API_KEY', 'MODEL', 'INPUT_MODEL', 'OPENCODE_MODEL',
'CLI_PROXY_API', 'CLI_PROXY_API_KEY', 'CLI_PROXY_API_MODEL', 'MODEL', 'INPUT_MODEL', 'OPENCODE_MODEL',
'AI_ASSISTANT_TIMEOUT_MS', 'AI_ASSISTANT_MAX_BUFFER',
];
@@ -57,6 +57,25 @@ describe('chat - CLIProxyAPI', async () => {
assert.equal(capturedOpts.headers.Authorization, 'Bearer secret');
});
it('omits model from the request body when auto selection is allowed', async () => {
process.env.CLI_PROXY_API = 'https://proxy.example';
process.env.CLI_PROXY_API_KEY = 'secret';
let capturedBody;
mock.method(axios, 'post', async (url, body) => {
capturedBody = body;
return {
data: { choices: [{ message: { content: 'cli response' } }] },
headers: {},
};
});
const result = await chat('sys', 'user');
assert.equal(result, 'cli response');
assert.equal(Object.hasOwn(capturedBody, 'model'), false);
});
it('throws an error when the API fails', async () => {
process.env.CLI_PROXY_API = 'https://proxy.example';
process.env.MODEL = 'gpt-5-mini';