fix(sdk): gate reasoning effort by runtime allowlist

This commit is contained in:
radioflyer28
2026-05-13 22:27:15 -04:00
parent c20f714d68
commit 810778e137
7 changed files with 80 additions and 6 deletions

View File

@@ -214,6 +214,8 @@ describe('resolveModel', () => {
it('returns runtime reasoning_effort from the same phase-tier source as model', async () => {
const { resolveModel } = await import('./config-query.js');
const { resolveRuntimeTierDefault } = await import('../model-catalog.js');
const opusCodexTier = resolveRuntimeTierDefault('codex', 'opus');
await writeFile(
join(tmpDir, '.planning', 'config.json'),
JSON.stringify({
@@ -228,10 +230,35 @@ describe('resolveModel', () => {
expect(executor).toMatchObject({
model: 'gpt-5.4',
profile: 'budget',
reasoning_effort: 'xhigh',
reasoning_effort: opusCodexTier?.reasoning_effort,
});
});
it('does not leak reasoning_effort from overrides for unsupported runtimes', async () => {
const { resolveModel } = await import('./config-query.js');
await writeFile(
join(tmpDir, '.planning', 'config.json'),
JSON.stringify({
model_profile: 'balanced',
runtime: 'opencode',
models: { planning: 'opus' },
model_profile_overrides: {
opencode: {
opus: { model: 'openrouter/openai/gpt-5.5', reasoning_effort: 'high' },
},
},
}),
);
const planner = (await resolveModel(['gsd-planner'], tmpDir)).data as Record<string, unknown>;
expect(planner).toMatchObject({
model: 'openrouter/openai/gpt-5.5',
profile: 'balanced',
});
expect(planner).not.toHaveProperty('reasoning_effort');
});
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'

View File

@@ -30,8 +30,11 @@ import {
VALID_PROFILES,
getAgentToModelMapForProfile,
resolveRuntimeTierDefault,
runtimesWithReasoningEffort,
} from '../model-catalog.js';
const RUNTIMES_WITH_REASONING_EFFORT = runtimesWithReasoningEffort();
// ─── configGet ──────────────────────────────────────────────────────────────
/**
@@ -151,7 +154,11 @@ function resolveRuntimeTier(config: Record<string, unknown>, tier: string): Runt
const userEntry = normalizeRuntimeTierEntry(runtimeOverrides?.[tier]);
if (!builtin && !userEntry) return null;
return { ...(builtin ?? {}), ...(userEntry ?? {}) };
const merged = { ...(builtin ?? {}), ...(userEntry ?? {}) };
if (!RUNTIMES_WITH_REASONING_EFFORT.has(runtime)) {
delete merged.reasoning_effort;
}
return merged;
}
/**