mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
fix: centralize model prefix handling to prevent provider errors
Moves prefix stripping from individual providers to AgentService/IdeationService and adds validation to ensure providers receive bare model IDs. This prevents bugs like the Codex CLI receiving "codex-gpt-5.1-codex-max" instead of the expected "gpt-5.1-codex-max". - Add validateBareModelId() helper with fail-fast validation - Add originalModel field to ExecuteOptions for logging - Update all providers to validate model has no prefix - Centralize prefix stripping in service layer - Remove redundant prefix stripping from individual providers Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,7 @@ import type { SettingsService } from './settings-service.js';
|
||||
import type { FeatureLoader } from './feature-loader.js';
|
||||
import { createChatOptions, validateWorkingDirectory } from '../lib/sdk-options.js';
|
||||
import { resolveModelString } from '@automaker/model-resolver';
|
||||
import { stripProviderPrefix } from '@automaker/types';
|
||||
|
||||
const logger = createLogger('IdeationService');
|
||||
|
||||
@@ -201,7 +202,7 @@ export class IdeationService {
|
||||
existingWorkContext
|
||||
);
|
||||
|
||||
// Resolve model alias to canonical identifier
|
||||
// Resolve model alias to canonical identifier (with prefix)
|
||||
const modelId = resolveModelString(options?.model ?? 'sonnet');
|
||||
|
||||
// Create SDK options
|
||||
@@ -214,9 +215,13 @@ export class IdeationService {
|
||||
|
||||
const provider = ProviderFactory.getProviderForModel(modelId);
|
||||
|
||||
// Strip provider prefix - providers need bare model IDs
|
||||
const bareModel = stripProviderPrefix(modelId);
|
||||
|
||||
const executeOptions: ExecuteOptions = {
|
||||
prompt: message,
|
||||
model: modelId,
|
||||
model: bareModel,
|
||||
originalModel: modelId,
|
||||
cwd: projectPath,
|
||||
systemPrompt: sdkOptions.systemPrompt,
|
||||
maxTurns: 1, // Single turn for ideation
|
||||
@@ -648,7 +653,7 @@ export class IdeationService {
|
||||
existingWorkContext
|
||||
);
|
||||
|
||||
// Resolve model alias to canonical identifier
|
||||
// Resolve model alias to canonical identifier (with prefix)
|
||||
const modelId = resolveModelString('sonnet');
|
||||
|
||||
// Create SDK options
|
||||
@@ -661,9 +666,13 @@ export class IdeationService {
|
||||
|
||||
const provider = ProviderFactory.getProviderForModel(modelId);
|
||||
|
||||
// Strip provider prefix - providers need bare model IDs
|
||||
const bareModel = stripProviderPrefix(modelId);
|
||||
|
||||
const executeOptions: ExecuteOptions = {
|
||||
prompt: prompt.prompt,
|
||||
model: modelId,
|
||||
model: bareModel,
|
||||
originalModel: modelId,
|
||||
cwd: projectPath,
|
||||
systemPrompt: sdkOptions.systemPrompt,
|
||||
maxTurns: 1,
|
||||
|
||||
Reference in New Issue
Block a user