Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions containers/api-proxy/model-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@ function resolveModel(requestedModel, aliases, availableModels, currentProvider,
const key = requestedModel.toLowerCase();
const fallbackConfig = normalizeFallbackConfig(modelFallbackConfig);

if (key === 'auto') {
Comment thread
Copilot marked this conversation as resolved.
Outdated
log.push('[model-resolver] special pass-through: "auto"');
return {
resolvedModel: requestedModel,
candidates: [requestedModel],
log,
fallback: fallbackConfig.enabled
? { activated: false, selection_method: 'middle_power_median', reason: 'direct_match' }
: undefined,
};
}

// Loop detection
if (chain.includes(key)) {
log.push(`[model-resolver] loop detected: "${requestedModel}" already in chain [${chain.join(' → ')}]`);
Expand Down
13 changes: 13 additions & 0 deletions containers/api-proxy/model-resolver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ describe('resolveModel', () => {
expect(result.resolvedModel).toBe('gpt-4o');
});

it('should treat the Copilot auto model as a pass-through', () => {
const result = resolveModel('auto', aliases, availableModels, 'copilot');
expect(result).not.toBeNull();
expect(result.resolvedModel).toBe('auto');
expect(result.fallback.activated).toBe(false);
});

it('should be case-insensitive for alias lookup', () => {
const result = resolveModel('SONNET', aliases, availableModels, 'copilot');
expect(result).not.toBeNull();
Expand Down Expand Up @@ -358,6 +365,12 @@ describe('rewriteModelInBody', () => {
expect(result).toBeNull(); // No rewrite needed
});

it('should not rewrite the Copilot auto model', () => {
const body = Buffer.from(JSON.stringify({ model: 'auto', messages: [] }));
const result = rewriteModelInBody(body, 'copilot', aliases, availableModels);
expect(result).toBeNull();
});

it('should return null for non-JSON body', () => {
const body = Buffer.from('not json');
const result = rewriteModelInBody(body, 'copilot', aliases, availableModels);
Expand Down
10 changes: 10 additions & 0 deletions containers/api-proxy/server.startup-model-validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ describe('validateRequestedModel', () => {
}));
});

it('treats the Copilot auto model as available without requiring it in provider model lists', () => {
process.env.AWF_REQUESTED_MODEL = 'auto';
cachedModels.copilot = ['gpt-4o', 'gpt-4o-mini'];
validateRequestedModel();
expect(logRequest).toHaveBeenCalledWith('info', 'model_validation', expect.objectContaining({
requested_model: 'auto',
resolved_via: 'direct',
}));
});

it('searches across multiple providers', () => {
process.env.AWF_REQUESTED_MODEL = 'claude-sonnet-4-5';
cachedModels.copilot = ['gpt-4o'];
Expand Down
21 changes: 21 additions & 0 deletions src/commands/validators/config-assembly-model-detection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ describe('config-assembly', () => {
);
});

it('should allow COPILOT_MODEL=auto', () => {
mockBuildConfigOnce({
copilotGithubToken: 'github_pat_testtoken',
});

const agentOptions = createMinimalAgentOptions();
agentOptions.additionalEnv = { COPILOT_MODEL: 'auto' };

expect(() => {
assembleAndValidateConfig(
{},
'echo test',
createMinimalLogAndLimits(),
createMinimalNetworkOptions(),
agentOptions,
);
}).not.toThrow();

expect(logger.error).not.toHaveBeenCalled();
});

it('should allow COPILOT_MODEL that matches a runtime alias key and resolves to a valid concrete model', () => {
mockBuildConfigOnce({
copilotGithubToken: 'github_pat_testtoken',
Expand Down
5 changes: 5 additions & 0 deletions src/copilot-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ describe('validateCopilotModel', () => {
expect(result).toEqual({ valid: true, resolvedModel: 'gpt-5.3-codex' });
});

it('accepts the Copilot auto model', () => {
const result = validateCopilotModel(' auto ');
expect(result).toEqual({ valid: true, resolvedModel: 'auto' });
});

it.each([
'gpt-4.5',
'gpt-5.1',
Expand Down
1 change: 1 addition & 0 deletions src/copilot-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const RETIRED_COPILOT_MODEL_ALIASES: Record<string, string> = {
* explicitly listed as a non-CLI model in the test's exclusion set).
*/
const SUPPORTED_COPILOT_MODELS = new Set([
'auto',
'gpt-4',
'gpt-4.1',
'gpt-4.5',
Expand Down