fix(sdk): inherit role thinking level on startup retry fallback
A retry-chain entry without its own :level suffix now inherits the unavailable primary's configured thinking level, matching runtime fallback-chain semantics. Regression test asserts a level that differs from the fallback model's default.
This commit is contained in:
@@ -2143,6 +2143,13 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
||||
let selectedModel = primary.model;
|
||||
let selectedThinkingLevel = primary.thinkingLevel;
|
||||
let selectedExplicitThinkingLevel = primary.explicitThinkingLevel;
|
||||
// A chain entry without its own `:level` suffix inherits the
|
||||
// unavailable primary's configured thinking level, matching
|
||||
// runtime fallback-chain semantics.
|
||||
if (retryFallback && !selectedExplicitThinkingLevel && retryFallback.originalThinkingLevel !== undefined) {
|
||||
selectedThinkingLevel = retryFallback.originalThinkingLevel;
|
||||
selectedExplicitThinkingLevel = true;
|
||||
}
|
||||
let authFallbackUsed = false;
|
||||
if (options.modelPatternAuthFallback) {
|
||||
const primaryKey = await modelRegistry.getApiKey(primary.model);
|
||||
|
||||
@@ -363,7 +363,7 @@ describe("createAgentSession deferred model pattern resolution", () => {
|
||||
authStorage.setRuntimeApiKey("runtime-provider", "test-key");
|
||||
authStoragesToClose.push(authStorage);
|
||||
const modelRegistry = new ModelRegistry(authStorage, path.join(tempDir, "missing-role-models.yml"));
|
||||
const parsed = parseArgs(["--model", "slow:high"]);
|
||||
const parsed = parseArgs(["--model", "slow:low"]);
|
||||
const exitSpy = vi.spyOn(process, "exit").mockImplementation((code?: number | string | null) => {
|
||||
throw new Error(`buildSessionOptions unexpectedly exited with ${code}`);
|
||||
});
|
||||
@@ -375,7 +375,7 @@ describe("createAgentSession deferred model pattern resolution", () => {
|
||||
modelRegistry,
|
||||
settings,
|
||||
);
|
||||
expect(cliOptions.modelPattern).toBe("slow:high");
|
||||
expect(cliOptions.modelPattern).toBe("slow:low");
|
||||
|
||||
const { session, modelFallbackMessage } = await createAgentSession({
|
||||
...cliOptions,
|
||||
@@ -398,7 +398,9 @@ describe("createAgentSession deferred model pattern resolution", () => {
|
||||
try {
|
||||
expect(session.model?.provider).toBe("runtime-provider");
|
||||
expect(session.model?.id).toBe("runtime-reasoning-model");
|
||||
expect(session.thinkingLevel).toBe(Effort.High);
|
||||
// `low` differs from the fallback model's default (`high`), so this
|
||||
// proves the suffix is inherited rather than the model default applied.
|
||||
expect(session.thinkingLevel).toBe(Effort.Low);
|
||||
expect(modelFallbackMessage).toBeUndefined();
|
||||
} finally {
|
||||
await session.dispose();
|
||||
|
||||
Reference in New Issue
Block a user