From afa2c6804a8039570f88e0a422d210ccda76c3f5 Mon Sep 17 00:00:00 2001 From: thecsguy <344173356+itsthecsguy@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:57:30 -0800 Subject: [PATCH 1/2] fix(client-runtime): recognize thought_level and role: reasoning in effort summaries --- .../threads/threadAgentsPresentation.ts | 3 +- .../src/state/threadExecution.test.ts | 66 +++++++++++++++++++ .../src/state/threadExecution.ts | 21 ++++-- 3 files changed, 84 insertions(+), 6 deletions(-) diff --git a/apps/mobile/src/features/threads/threadAgentsPresentation.ts b/apps/mobile/src/features/threads/threadAgentsPresentation.ts index ae1fe531eefb2..270cc1f3d7fbe 100644 --- a/apps/mobile/src/features/threads/threadAgentsPresentation.ts +++ b/apps/mobile/src/features/threads/threadAgentsPresentation.ts @@ -219,7 +219,8 @@ export function workflowMemberMetadata( const effortChoice = provider?.models .find((candidate) => candidate.slug === slug) ?.capabilities?.optionDescriptors?.flatMap((descriptor) => - descriptor.type === "select" && REASONING_EFFORT_OPTION_IDS.includes(descriptor.id) + descriptor.type === "select" && + (descriptor.role === "reasoning" || REASONING_EFFORT_OPTION_IDS.includes(descriptor.id)) ? descriptor.options : [], ) diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index 2984bb97dbaeb..ac3ec4799075e 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -32,6 +32,7 @@ import { deriveThreadActivityRun, deriveThreadRuntime, formatModelSelectionEffort, + formatSubagentEffort, isBackgroundWorkStopPending, presentPendingBackgroundWork, presentProviderGoal, @@ -761,6 +762,71 @@ describe("formatModelSelectionEffort", () => { expect(formatModelSelectionEffort(selection, models)).toBe("Extra High"); }); + + it("reads ACP thought_level and role: reasoning controls for cataloged and uncataloged models", () => { + const models = [ + { + slug: "gemini-4-neon", + name: "Gemini 4 Neon", + isCustom: false, + capabilities: createModelCapabilities({ + optionDescriptors: [ + { + id: "thought_level", + label: "Thinking", + type: "select", + role: "reasoning", + options: [ + { id: "medium", label: "Medium", isDefault: true }, + { id: "high", label: "High" }, + ], + }, + ], + }), + }, + { + slug: "acp-custom-agent", + name: "ACP Custom Agent", + isCustom: false, + capabilities: createModelCapabilities({ + optionDescriptors: [ + { + id: "custom_thinking_mode", + label: "Thinking", + type: "select", + role: "reasoning", + options: [{ id: "deep", label: "Deep" }], + }, + ], + }), + }, + ]; + const antigravitySelection = createModelSelection( + ProviderInstanceId.make("antigravity"), + "gemini-4-neon", + [{ id: "thought_level", value: "high" }], + ); + const customSelection = createModelSelection( + ProviderInstanceId.make("acpRegistry"), + "acp-custom-agent", + [{ id: "custom_thinking_mode", value: "deep" }], + ); + const uncatalogedSelection = createModelSelection( + ProviderInstanceId.make("antigravity"), + "gemini-4-neon-preview", + [{ id: "thought_level", value: "high" }], + ); + + expect(formatModelSelectionEffort(antigravitySelection, models)).toBe("High"); + expect(formatModelSelectionEffort(customSelection, models)).toBe("Deep"); + expect( + formatSubagentEffort({ + modelSlug: "gemini-4-neon-preview", + modelSelection: uncatalogedSelection, + provider: { driver: ProviderDriverKind.make("antigravity"), models }, + }), + ).toBe("high"); + }); }); describe("isBackgroundWorkStopPending", () => { diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index 033930e254f57..b234c4e460a36 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -233,6 +233,7 @@ export const REASONING_EFFORT_OPTION_IDS: ReadonlyArray = [ "variant", "reasoning_effort", "thinking_level", + "thought_level", ]; export function formatModelSelectionEffort( @@ -244,11 +245,21 @@ export function formatModelSelectionEffort( if (!caps) return null; const options = withLegacyUltracodeEffort(caps.optionDescriptors, selection.options); const current = options ? { ...selection, options } : selection; - for (const id of REASONING_EFFORT_OPTION_IDS) { - const descriptor = caps.optionDescriptors?.find((candidate) => candidate.id === id); - if (descriptor?.type !== "select") continue; - const value = getProviderOptionStatedValue(id, current, reportedSelection); - if (value === undefined && id !== "variant") continue; + const selectDescriptors = (caps.optionDescriptors ?? []).filter( + (candidate) => candidate.type === "select", + ); + const reasoningDescriptors = [ + ...selectDescriptors.filter((candidate) => candidate.role === "reasoning"), + ...REASONING_EFFORT_OPTION_IDS.flatMap((id) => { + const descriptor = selectDescriptors.find( + (candidate) => candidate.id === id && candidate.role !== "reasoning", + ); + return descriptor ? [descriptor] : []; + }), + ]; + for (const descriptor of reasoningDescriptors) { + const value = getProviderOptionStatedValue(descriptor.id, current, reportedSelection); + if (value === undefined && descriptor.id !== "variant") continue; if (typeof value === "boolean") continue; // Bypass picker normalization so an obsolete choice cannot become a catalog default. const label = getProviderOptionCurrentLabel( From 9ddacfe185015919b69c166acfd289011013a1ca Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 21 Nov 2026 06:43:37 +0000 Subject: [PATCH 2/2] fix(web): subagent tooltips read role: reasoning effort options The tooltip found effort only by the known option ids, so an ACP model whose reasoning control has its own id showed no effort. A shared readSelectedEffortValue now checks the model's role: reasoning descriptors first, and formatSubagentEffort's fallback uses it too. Co-Authored-By: Claude Opus 5.5 --- .../chat/SubagentTooltipContent.tsx | 15 ++++++------- .../src/state/threadExecution.test.ts | 4 ++++ .../src/state/threadExecution.ts | 21 ++++++++++++++++--- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/web/src/components/chat/SubagentTooltipContent.tsx b/apps/web/src/components/chat/SubagentTooltipContent.tsx index 229e5eda6a884..722968fb6241a 100644 --- a/apps/web/src/components/chat/SubagentTooltipContent.tsx +++ b/apps/web/src/components/chat/SubagentTooltipContent.tsx @@ -11,12 +11,8 @@ import { resolveSubagentMetadata, subagentDetailPreview, } from "@t3tools/client-runtime/state/subagent-display"; -import { REASONING_EFFORT_OPTION_IDS } from "@t3tools/client-runtime/state/thread-execution"; -import { - DEFAULT_VARIANT_CHOICE_ID, - getModelSelectionStringOptionValue, - resolveSelectableModel, -} from "@t3tools/shared/model"; +import { readSelectedEffortValue } from "@t3tools/client-runtime/state/thread-execution"; +import { resolveSelectableModel } from "@t3tools/shared/model"; import { getTraitsSpeedDisplay, TraitsSpeedIcon } from "./TraitsSpeed"; import { useGT, useMessages } from "gt-react"; import type { ReactNode } from "react"; @@ -83,9 +79,10 @@ export function SubagentTooltipContent(props: { childModel === modelSlug && childSelection?.instanceId === props.providerInstanceId ? childSelection : undefined; - const effort = REASONING_EFFORT_OPTION_IDS.map((id) => - getModelSelectionStringOptionValue(matchingSelection, id), - ).find((value) => value && value !== DEFAULT_VARIANT_CHOICE_ID); + const effort = readSelectedEffortValue( + matchingSelection, + providerModel?.capabilities?.optionDescriptors, + ); const speed = provider ? providerModel?.capabilities?.optionDescriptors ?.map((descriptor) => { diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index ac3ec4799075e..d932e2c0395b3 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -37,6 +37,7 @@ import { presentPendingBackgroundWork, presentProviderGoal, presentRunStop, + readSelectedEffortValue, threadRuntimeHasInterruptibleRun, } from "./threadExecution.ts"; @@ -826,6 +827,9 @@ describe("formatModelSelectionEffort", () => { provider: { driver: ProviderDriverKind.make("antigravity"), models }, }), ).toBe("high"); + expect( + readSelectedEffortValue(customSelection, models[1]?.capabilities?.optionDescriptors), + ).toBe("deep"); }); }); diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index 48a7eddf53b26..7e5ad55dc53b2 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -16,6 +16,7 @@ import { type OrchestrationV2PendingBackgroundTask, type OrchestrationV2ProviderGoal, type OrchestrationV2ProviderSession, + type ProviderOptionDescriptor, type ServerProvider, type ServerProviderModel, type OrchestrationV2ExecutionNode, @@ -288,10 +289,24 @@ export function formatSubagentEffort(input: { if (provider.models.some((model) => model.slug === modelSlug)) { return formatModelSelectionEffort({ ...selection, model: modelSlug }, provider.models); } + return readSelectedEffortValue(selection); +} + +/** The raw saved effort, preferring the option the model marks as its reasoning control. */ +export function readSelectedEffortValue( + selection: ModelSelection | undefined, + descriptors: ReadonlyArray = [], +): string | null { + const ids = [ + ...descriptors.flatMap((descriptor) => + descriptor.type === "select" && descriptor.role === "reasoning" ? [descriptor.id] : [], + ), + ...REASONING_EFFORT_OPTION_IDS, + ]; return ( - REASONING_EFFORT_OPTION_IDS.map((id) => getModelSelectionStringOptionValue(selection, id)).find( - (value) => value && value !== DEFAULT_VARIANT_CHOICE_ID, - ) ?? null + ids + .map((id) => getModelSelectionStringOptionValue(selection, id)) + .find((value) => value && value !== DEFAULT_VARIANT_CHOICE_ID) ?? null ); }