diff --git a/sdk/src/query/config-query.test.ts b/sdk/src/query/config-query.test.ts index 03cf0e98d..634363305 100644 --- a/sdk/src/query/config-query.test.ts +++ b/sdk/src/query/config-query.test.ts @@ -165,6 +165,31 @@ describe('resolveModel', () => { const data = result.data as Record; expect(data).toHaveProperty('model', ''); }); + + it('resolveModel uses workstream config when --ws is specified', async () => { + const { resolveModel } = await import('./config-query.js'); + // Root config: balanced profile → gsd-executor resolves to 'sonnet' + await writeFile( + join(tmpDir, '.planning', 'config.json'), + JSON.stringify({ model_profile: 'balanced' }), + ); + // Workstream config: quality profile → gsd-executor resolves to 'opus' + await mkdir(join(tmpDir, '.planning', 'workstreams', 'frontend'), { recursive: true }); + await writeFile( + join(tmpDir, '.planning', 'workstreams', 'frontend', 'config.json'), + JSON.stringify({ model_profile: 'quality' }), + ); + + const rootResult = await resolveModel(['gsd-executor'], tmpDir); + const rootData = rootResult.data as Record; + expect(rootData.profile).toBe('balanced'); + expect(rootData.model).toBe('sonnet'); + + const wsResult = await resolveModel(['gsd-executor'], tmpDir, 'frontend'); + const wsData = wsResult.data as Record; + expect(wsData.profile).toBe('quality'); + expect(wsData.model).toBe('opus'); + }); }); // ─── MODEL_PROFILES ───────────────────────────────────────────────────────── diff --git a/sdk/src/query/config-query.ts b/sdk/src/query/config-query.ts index c949eb06d..bc22ba6be 100644 --- a/sdk/src/query/config-query.ts +++ b/sdk/src/query/config-query.ts @@ -144,16 +144,18 @@ export const configPath: QueryHandler = async (_args, projectDir, workstream) => * * @param args - args[0] is the agent type (e.g., 'gsd-planner') * @param projectDir - Project root directory + * @param workstream - Optional workstream name; forwarded to loadConfig so per-workstream + * model_profile settings are respected (mirrors configGet/configPath behavior) * @returns QueryResult with { model, profile } or { model, profile, unknown_agent: true } * @throws GSDError with Validation classification if agent type not provided */ -export const resolveModel: QueryHandler = async (args, projectDir) => { +export const resolveModel: QueryHandler = async (args, projectDir, workstream) => { const agentType = args[0]; if (!agentType) { throw new GSDError('agent-type required', ErrorClassification.Validation); } - const config = await loadConfig(projectDir); + const config = await loadConfig(projectDir, workstream); const profile = String(config.model_profile || 'balanced').toLowerCase(); // Check per-agent override first