From 6eddb9fd78ec5985ac78df48895eb9d8a9dfb1a5 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 20 Aug 2026 23:47:31 -0700 Subject: [PATCH] fix: preserve agent scope in thinking projections --- .../run/runtime-resolution.test.ts | 28 +++++++++++++++++++ src/agents/model-thinking-default.ts | 1 + src/agents/tools/session-status-tool.ts | 1 + .../reply/get-reply-native-slash-fast-path.ts | 1 + 4 files changed, 31 insertions(+) diff --git a/src/agents/embedded-agent-runner/run/runtime-resolution.test.ts b/src/agents/embedded-agent-runner/run/runtime-resolution.test.ts index 13992bca51b7..3c2910400b7c 100644 --- a/src/agents/embedded-agent-runner/run/runtime-resolution.test.ts +++ b/src/agents/embedded-agent-runner/run/runtime-resolution.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; +import { resolveThinkingDefaultWithRuntimeCatalog } from "../../model-thinking-default.js"; import { resolveInitialThinkLevel, resolveRequestStreamTransportOverrides, @@ -50,3 +51,30 @@ describe("resolveInitialThinkLevel", () => { ).toBe("high"); }); }); + +describe("resolveThinkingDefaultWithRuntimeCatalog", () => { + it("preserves agent scope through the runtime-catalog lookup", async () => { + await expect( + resolveThinkingDefaultWithRuntimeCatalog({ + cfg: { + agents: { + defaults: { + models: { "openai/gpt-5.5": { params: { thinking: "low" } } }, + }, + entries: { + audit: { + models: { "openai/gpt-5.5": { params: { thinking: "high" } } }, + }, + }, + }, + }, + provider: "openai", + model: "gpt-5.5", + agentId: "audit", + loadRuntimeCatalog: async () => [ + { provider: "openai", id: "gpt-5.5", name: "gpt-5.5", reasoning: true }, + ], + }), + ).resolves.toBe("high"); + }); +}); diff --git a/src/agents/model-thinking-default.ts b/src/agents/model-thinking-default.ts index caddbd32c259..f071189613be 100644 --- a/src/agents/model-thinking-default.ts +++ b/src/agents/model-thinking-default.ts @@ -65,5 +65,6 @@ export async function resolveThinkingDefaultWithRuntimeCatalog(params: { model: params.model, catalog, agentRuntime: params.agentRuntime, + agentId: params.agentId, }); } diff --git a/src/agents/tools/session-status-tool.ts b/src/agents/tools/session-status-tool.ts index ccb3942617cd..5d37faaa7c28 100644 --- a/src/agents/tools/session-status-tool.ts +++ b/src/agents/tools/session-status-tool.ts @@ -1163,6 +1163,7 @@ export function createSessionStatusTool(opts?: { cfg, provider: providerForCard, model: defaultModelForCard, + agentId, loadRuntimeCatalog: () => loadPreparedModelCatalog({ config: cfg, diff --git a/src/auto-reply/reply/get-reply-native-slash-fast-path.ts b/src/auto-reply/reply/get-reply-native-slash-fast-path.ts index 9cc05e32a1cd..1a5533cc48c4 100644 --- a/src/auto-reply/reply/get-reply-native-slash-fast-path.ts +++ b/src/auto-reply/reply/get-reply-native-slash-fast-path.ts @@ -115,6 +115,7 @@ async function resolveNativeSlashDefaultThinkingLevel(params: { cfg: params.cfg, provider: params.provider, model: params.model, + agentId: params.agentId, loadRuntimeCatalog: () => loadPreparedModelCatalog({ config: params.cfg,