The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 03:15 UTC
feat(claude): Ultracode works with any effort, like Claude Desktop (#27034)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Bilal Bakr committed
Nov 5, 2026 at 23:32 UTC
2d0efd35840dd3118939cd27b096340ea522a541
27 files changed
+585
-66
apps/mobile/src/features/threads/SubagentRow.tsx
+7
-1
@@ -5,6 +5,7 @@ import {
5
shouldShowInstanceBadge,
6
} from "@t3tools/client-runtime/state/provider-instance-display";
7
import { resolveSubagentMetadata } from "@t3tools/client-runtime/state/subagent-display";
8
+import { formatSubagentEffort } from "@t3tools/client-runtime/state/thread-execution";
9
import type { EnvironmentId, OrchestrationV2Subagent } from "@t3tools/contracts";
10
import type { ReactNode } from "react";
11
import { View } from "react-native";
@@ -23,6 +24,7 @@ type SubagentRowSubagent = Pick<
24
| "threadId"
25
| "childThreadId"
26
| "model"
27
+ | "modelSelection"
28
| "driver"
29
| "providerInstanceId"
30
| "title"
@@ -132,14 +134,17 @@ function SubagentMetadata(props: {
134
parent ? scopeProjectRef(environmentId, parent.projectId) : null,
135
);
136
const childProject = useProject(child ? scopeProjectRef(environmentId, child.projectId) : null);
135
- const { modelLabel, workspace } = resolveSubagentMetadata({
137
+ const selection = subagent.modelSelection;
138
+ const { modelLabel, modelSlug, workspace } = resolveSubagentMetadata({
139
model: subagent.model,
140
+ modelSelection: selection,
141
provider,
142
parentThread: parent,
143
childThread: child,
144
parentProject,
145
childProject,
146
});
147
+ const effort = formatSubagentEffort({ modelSlug, modelSelection: selection, provider });
148
return (
149
<View className="min-w-0 flex-row items-center gap-1.5">
150
{showBadge ? (
@@ -161,6 +166,7 @@ function SubagentMetadata(props: {
166
<Text className="min-w-0 shrink text-xs text-foreground-muted" numberOfLines={1}>
167
{provider ? `${resolveProviderInstanceDisplayName(provider)} · ` : ""}
168
{modelLabel}
169
+ {effort ? ` · ${effort}` : ""}
170
</Text>
171
{workspace.map(({ label, value }) => (
172
// Preserve the label against flattening without making it a separate accessibility stop.
apps/mobile/src/features/threads/thread-subagent-group.tsx
+1
@@ -128,6 +128,7 @@ export function ThreadSubagentGroup(props: {
128
result: live?.result ?? item.result,
129
progress: live?.progress ?? item.progress,
130
model: live?.model ?? null,
131
+ modelSelection: live?.modelSelection,
132
};
133
});
134
const grouped = agents.length > 1;
apps/mobile/src/features/threads/thread-workflow-opening.tsx
+2
@@ -2,6 +2,7 @@ import { useAtomValue } from "@effect/atom-react";
2
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
3
import {
4
resolveWorkflowOpening,
5
+ workflowMemberModelSelection,
6
workflowOpeningHeadline,
7
workflowOpeningParentThreadId,
8
type RuntimeSubagent,
@@ -63,6 +64,7 @@ function memberRowSubagent(
64
threadId: coordinatorThreadId,
65
childThreadId: member.childThreadId as ThreadId | null,
66
model: member.model,
67
+ modelSelection: workflowMemberModelSelection(member, opening.providerInstanceId!),
68
driver: opening.driver!,
69
providerInstanceId: opening.providerInstanceId!,
70
title: member.title,
apps/server/src/claudeModelOptions.test.ts
+67
@@ -3,6 +3,10 @@ import { describe, expect, it } from "@effect/vitest";
3
import { ProviderInstanceId, type ModelSelection } from "@t3tools/contracts";
4
5
import { compileClaudeModelSelection } from "./claudeModelOptions.ts";
6
+import {
7
+ BUNDLED_CLAUDE_MODEL_CATALOG,
8
+ scopeClaudeModelCatalog,
9
+} from "./provider/ClaudeModelCatalog.ts";
10
11
const selection = (
12
model: string,
@@ -30,6 +34,69 @@ describe("compileClaudeModelSelection", () => {
34
});
35
});
36
37
+ it("runs Ultracode at the chosen effort and reads the old Ultracode effort as xhigh", () => {
38
+ expect(
39
+ compileClaudeModelSelection(
40
+ selection("claude-opus-5-5", [
41
+ { id: "effort", value: "high" },
42
+ { id: "ultracode", value: true },
43
+ ]),
44
+ ),
45
+ ).toMatchObject({ effort: "high", settings: { ultracode: true } });
46
+ expect(
47
+ compileClaudeModelSelection(
48
+ selection("claude-opus-5-5", [{ id: "effort", value: "ultracode" }]),
49
+ ),
50
+ ).toMatchObject({ effort: "xhigh", settings: { ultracode: true } });
51
+ const legacyTurnedOff = compileClaudeModelSelection(
52
+ selection("claude-opus-5-5", [
53
+ { id: "effort", value: "ultracode" },
54
+ { id: "ultracode", value: false },
55
+ ]),
56
+ );
57
+ expect(legacyTurnedOff.effort).toBe("xhigh");
58
+ expect(legacyTurnedOff.settings.ultracode).toBe(false);
59
+ expect(
60
+ compileClaudeModelSelection(selection("claude-opus-5-5", [{ id: "effort", value: "high" }]))
61
+ .settings,
62
+ ).not.toHaveProperty("ultracode");
63
+ });
64
+
65
+ it("keeps old Ultracode defaults and selections at Extra High on custom models", () => {
66
+ const customModel = (slug: string, choices: ReadonlyArray<string>) => ({
67
+ slug,
68
+ name: slug,
69
+ capabilities: {
70
+ optionDescriptors: [
71
+ {
72
+ id: "effort",
73
+ label: "Reasoning",
74
+ type: "select" as const,
75
+ currentValue: "ultracode",
76
+ options: choices.map((id) => ({ id, label: id, isDefault: id === "ultracode" })),
77
+ },
78
+ ],
79
+ },
80
+ });
81
+ const catalog = scopeClaudeModelCatalog(BUNDLED_CLAUDE_MODEL_CATALOG, [
82
+ customModel("claude-custom-tuned", ["high", "xhigh", "ultracode"]),
83
+ customModel("claude-custom-no-xhigh", ["high", "ultracode"]),
84
+ ]);
85
+
86
+ for (const model of ["claude-custom-tuned", "claude-custom-no-xhigh"]) {
87
+ expect(compileClaudeModelSelection(selection(model, []), catalog)).toMatchObject({
88
+ effort: "xhigh",
89
+ settings: { ultracode: true },
90
+ });
91
+ expect(
92
+ compileClaudeModelSelection(
93
+ selection(model, [{ id: "effort", value: "ultracode" }]),
94
+ catalog,
95
+ ),
96
+ ).toMatchObject({ effort: "xhigh", settings: { ultracode: true } });
97
+ }
98
+ });
99
+
100
it("uses the model default SDK effort alongside prompt-injected effort", () => {
101
expect(
102
compileClaudeModelSelection(
apps/server/src/claudeModelOptions.ts
+6
-3
@@ -9,7 +9,6 @@ import {
9
import {
10
BUNDLED_CLAUDE_MODEL_CATALOG,
11
getClaudeCatalogModelCapabilities,
12
- isClaudeCatalogUltracodeEffort,
12
normalizeClaudeCatalogEffort,
13
resolveClaudeCatalogApiModelId,
14
resolveClaudeCatalogEffort,
@@ -29,7 +28,10 @@ export function compileClaudeModelSelection(
28
catalog: ClaudeModelCatalog = BUNDLED_CLAUDE_MODEL_CATALOG,
29
): CompiledClaudeModelSelection {
30
const capabilities = getClaudeCatalogModelCapabilities(catalog, selection.model);
32
- const descriptors = getProviderOptionDescriptors({ caps: capabilities });
31
+ const descriptors = getProviderOptionDescriptors({
32
+ caps: capabilities,
33
+ selections: selection.options,
34
+ });
35
const supportsBoolean = (id: string) =>
36
descriptors.some((descriptor) => descriptor.type === "boolean" && descriptor.id === id);
37
const rawEffort = getModelSelectionStringOptionValue(selection, "effort");
@@ -41,10 +43,11 @@ export function compileClaudeModelSelection(
43
const thinking = supportsBoolean("thinking")
44
? getModelSelectionBooleanOptionValue(selection, "thinking")
45
: undefined;
46
+ const ultracode = descriptors.find((descriptor) => descriptor.id === "ultracode")?.currentValue;
47
const settings = {
48
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
49
...(typeof fastMode === "boolean" ? { fastMode } : {}),
47
- ...(isClaudeCatalogUltracodeEffort(resolvedEffort) ? { ultracode: true } : {}),
50
+ ...(typeof ultracode === "boolean" ? { ultracode } : {}),
51
};
52
const apiModelId = resolveClaudeCatalogApiModelId(catalog, selection);
53
const promptEffort = resolvePromptInjectedEffort(capabilities, rawEffort) ?? undefined;
apps/server/src/mcp/OrchestratorMcpService.test.ts
+39
-6
@@ -3128,6 +3128,18 @@ describe("OrchestratorMcpService provider resolution", () => {
3128
target: { providerInstanceId: peerId, options: { reasoningEffort: "max" } },
3129
expected: { instanceId: peerId, model: inherited.model, options: override },
3130
},
3131
+ {
3132
+ name: "old Ultracode effort level",
3133
+ target: { model: "ultracode-model", options: { effort: "ultracode" } },
3134
+ expected: {
3135
+ instanceId: codexInstanceId,
3136
+ model: "ultracode-model",
3137
+ options: [
3138
+ { id: "effort", value: "xhigh" },
3139
+ { id: "ultracode", value: true },
3140
+ ],
3141
+ },
3142
+ },
3143
] as const;
3144
for (const testCase of cases) {
3145
const commands: Array<unknown> = [];
@@ -3170,12 +3182,33 @@ describe("OrchestratorMcpService provider resolution", () => {
3182
driver,
3183
model: inherited.model,
3184
}),
3173
- models: [inherited.model, "other-model"].map((model) => ({
3174
- slug: model,
3175
- name: model,
3176
- isCustom: false,
3177
- capabilities: null,
3178
- })),
3185
+ models: [
3186
+ ...[inherited.model, "other-model"].map((model) => ({
3187
+ slug: model,
3188
+ name: model,
3189
+ isCustom: false,
3190
+ capabilities: null,
3191
+ })),
3192
+ {
3193
+ slug: "ultracode-model",
3194
+ name: "ultracode-model",
3195
+ isCustom: false,
3196
+ capabilities: {
3197
+ optionDescriptors: [
3198
+ {
3199
+ id: "effort",
3200
+ label: "Reasoning",
3201
+ type: "select",
3202
+ options: [
3203
+ { id: "high", label: "High" },
3204
+ { id: "xhigh", label: "Extra High" },
3205
+ ],
3206
+ },
3207
+ { id: "ultracode", label: "Ultracode", type: "boolean" },
3208
+ ],
3209
+ },
3210
+ },
3211
+ ],
3212
},
3213
providerSnapshot({ instanceId: peerId, driver, model: inherited.model }),
3214
]),
apps/server/src/mcp/OrchestratorMcpService.ts
+6
-3
@@ -66,7 +66,7 @@ import {
66
resolveProjectProviderInstanceEnabled,
67
SECRET_REQUEST_UNSAVED_NOTE,
68
} from "@t3tools/contracts";
69
-import { getProviderOptionCurrentValue } from "@t3tools/shared/model";
69
+import { getProviderOptionCurrentValue, withLegacyUltracodeEffort } from "@t3tools/shared/model";
70
import { runRanAfter } from "@t3tools/shared/orchestrationV2ThreadError";
71
import { formatThreadLink } from "@t3tools/shared/threadLinks";
72
import {
@@ -1436,7 +1436,7 @@ const make = Effect.gen(function* () {
1436
1437
const descriptors = provider.models.find((candidate) => candidate.slug === model)?.capabilities
1438
?.optionDescriptors;
1439
- const requestedOptions = input.target?.options;
1439
+ const requestedOptions = withLegacyUltracodeEffort(descriptors, input.target?.options);
1440
if (requestedOptions !== undefined) {
1441
const invalid = invalidOptionSelections(requestedOptions, descriptors);
1442
if (invalid.length > 0) {
@@ -1450,7 +1450,10 @@ const make = Effect.gen(function* () {
1450
const inheritsOptions =
1451
instanceId === inheritedSelection.instanceId && model === inheritedSelection.model;
1452
let options = inheritsOptions
1453
- ? knownOptions(inheritedSelection.options, descriptors)
1453
+ ? knownOptions(
1454
+ withLegacyUltracodeEffort(descriptors, inheritedSelection.options),
1455
+ descriptors,
1456
+ )
1457
: undefined;
1458
if (requestedOptions !== undefined) {
1459
const selections = new Map(
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+63
-2
@@ -150,6 +150,26 @@ const CUSTOM_MODEL_CLAUDE_SETTINGS = Schema.decodeSync(ClaudeSettings)({
150
},
151
],
152
});
153
+const ULTRACODE_CUSTOM_MODEL_CLAUDE_SETTINGS = Schema.decodeSync(ClaudeSettings)({
154
+ customModels: [
155
+ {
156
+ slug: "claude-custom-tuned",
157
+ capabilities: {
158
+ optionDescriptors: [
159
+ {
160
+ id: "effort",
161
+ label: "Reasoning",
162
+ type: "select",
163
+ options: [
164
+ { id: "high", label: "High", isDefault: true },
165
+ { id: "ultracode", label: "Ultracode" },
166
+ ],
167
+ },
168
+ ],
169
+ },
170
+ },
171
+ ],
172
+});
173
const CLAUDE_TEST_MODEL_SELECTION = {
174
instanceId: ProviderInstanceId.make(ClaudeAdapterV2.CLAUDE_PROVIDER),
175
model: "claude-sonnet-4-6",
@@ -5836,7 +5856,8 @@ describe("ClaudeAdapterV2 background wake turns", () => {
5856
turn(3, {
5857
...normal,
5858
options: [
5839
- { id: "effort", value: "ultracode" },
5859
+ { id: "effort", value: "high" },
5860
+ { id: "ultracode", value: true },
5861
{ id: "fastMode", value: true },
5862
],
5863
}),
@@ -5845,7 +5866,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
5866
yield* harness.runtime.startTurn(turn(4, { ...normal, model: "claude-sonnet-4-6" }));
5867
yield* settle;
5868
assert.deepEqual(harness.liveSelectionChanges, [
5848
- { effortLevel: "xhigh", fastMode: true, ultracode: true },
5869
+ { effortLevel: "high", fastMode: true, ultracode: true },
5870
{ model: "claude-sonnet-4-6" },
5871
{ effortLevel: "high", fastMode: null, ultracode: null },
5872
]);
@@ -14871,6 +14892,46 @@ describe("ClaudeAdapterV2 background wake turns", () => {
14892
),
14893
);
14894
14895
+ it.effect("sends Ultracode with any effort on a custom model", () =>
14896
+ Effect.scoped(
14897
+ Effect.gen(function* () {
14898
+ const harness = yield* makeWakeHarnessWithOptions({
14899
+ settings: ULTRACODE_CUSTOM_MODEL_CLAUDE_SETTINGS,
14900
+ });
14901
+ yield* harness.runtime.startTurn(
14902
+ makeClaudeTestTurnInput({
14903
+ threadId: harness.threadId,
14904
+ providerThread: harness.providerThread,
14905
+ now: yield* DateTime.now,
14906
+ attemptId: RunAttemptId.make("attempt-custom-ultracode"),
14907
+ text: "Plan the work.",
14908
+ attachments: [],
14909
+ modelSelection: {
14910
+ instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
14911
+ model: "claude-custom-tuned",
14912
+ options: [
14913
+ { id: "effort", value: "high" },
14914
+ { id: "ultracode", value: true },
14915
+ ],
14916
+ },
14917
+ }),
14918
+ );
14919
+ const options = harness.getOpenedOptions()!;
14920
+ assert.equal(options.effort, "high");
14921
+ assert.equal((options.settings as { ultracode?: boolean }).ultracode, true);
14922
+ }).pipe(
14923
+ Effect.provide(
14924
+ Layer.mergeAll(
14925
+ IdAllocator.layer,
14926
+ McpProviderSessions.layer,
14927
+ NodeServices.layer,
14928
+ NodeCrypto.layer,
14929
+ ),
14930
+ ),
14931
+ ),
14932
+ ),
14933
+ );
14934
+
14935
it.effect("resolves a subagent's model and effort against the instance's custom models", () =>
14936
Effect.scoped(
14937
Effect.gen(function* () {
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+18
-10
@@ -1750,6 +1750,7 @@ const subagentDeviceInstructions: HookCallback = () =>
1750
1751
export function makeClaudeQueryOptions(input: {
1752
readonly modelSelection: ModelSelection;
1753
+ readonly modelCatalog?: ClaudeModelCatalog;
1754
readonly nativeThreadId: string;
1755
readonly title?: string;
1756
readonly resume: boolean;
@@ -1775,7 +1776,7 @@ export function makeClaudeQueryOptions(input: {
1776
// Flag settings, because a user's settings.json env beats the process env in Claude Code.
1777
readonly toolSearchOverride?: "true";
1778
}): ClaudeAgentSdkQueryOptions {
1778
- const compiledSelection = compileClaudeModelSelection(input.modelSelection);
1779
+ const compiledSelection = compileClaudeModelSelection(input.modelSelection, input.modelCatalog);
1780
const {
1781
// claudeLaunchArgDirectories reads every --add-dir into additionalDirectories.
1782
"add-dir": _launchArgAddDir,
@@ -4852,7 +4853,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
4853
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4854
const serverSettings = yield* Effect.serviceOption(ServerSettings.ServerSettingsService);
4855
const { attachmentsDir, fileSystem, path, random, idAllocator, queryRunner } = adapterOptions;
4855
- const subagentModelCatalog = scopeClaudeModelCatalog(
4856
+ const modelCatalog = scopeClaudeModelCatalog(
4857
BUNDLED_CLAUDE_MODEL_CATALOG,
4858
adapterOptions.settings.customModels,
4859
);
@@ -6789,7 +6790,8 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
6790
existingSubagent === undefined
6791
? (input.effort ??
6792
input.owner?.effort ??
6792
- compileClaudeModelSelection(input.context.input.modelSelection).effort)
6793
+ compileClaudeModelSelection(input.context.input.modelSelection, modelCatalog)
6794
+ .effort)
6795
: existingSubagent.effort;
6796
const model = input.model ?? priorTask?.model ?? null;
6797
const task = {
@@ -6827,7 +6829,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
6829
...(existingSubagent === undefined || existingSubagent.task.modelSelection !== undefined
6830
? {
6831
modelSelection: claudeSubagentModelSelection(
6830
- subagentModelCatalog,
6832
+ modelCatalog,
6833
input.context.input.modelSelection.instanceId,
6834
model || input.context.input.modelSelection.model,
6835
effort,
@@ -9328,7 +9330,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9330
const model =
9331
snapshotModel.length === 0 || snapshotModel === "<synthetic>"
9332
? undefined
9331
- : canonicalClaudeSubagentModel(subagentModelCatalog, snapshotModel);
9333
+ : canonicalClaudeSubagentModel(modelCatalog, snapshotModel);
9334
if (parentToolUseId !== null && model !== undefined) {
9335
const subagent = yield* resolveSubagentByToolUseId(context, parentToolUseId);
9336
if (subagent === undefined) {
@@ -9634,7 +9636,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9636
const nativeToolInput = claudeNativeToolInputFromUnknown(toolUse.input);
9637
if (toolUse.name === "Agent") {
9638
rememberClaudeSubagentLaunch(
9637
- subagentModelCatalog,
9639
+ modelCatalog,
9640
context,
9641
pendingSubagentLaunchesByToolUseId,
9642
toolUse.id,
@@ -10234,7 +10236,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
10236
const startToolCall = toolName !== "Agent" && options?.startToolCall !== false;
10237
if (toolName === "Agent") {
10238
rememberClaudeSubagentLaunch(
10237
- subagentModelCatalog,
10239
+ modelCatalog,
10240
context,
10241
pendingSubagentLaunchesByToolUseId,
10242
nativeRequestId,
@@ -10737,7 +10739,10 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
10739
: { allowedTools: queryPolicy.allowedTools }),
10740
});
10741
const queryPolicyKey = claudeEffectiveQueryPolicyKey(queryPolicy, mcpOverrides);
10740
- const compiledSelection = compileClaudeModelSelection(turnInput.modelSelection);
10742
+ const compiledSelection = compileClaudeModelSelection(
10743
+ turnInput.modelSelection,
10744
+ modelCatalog,
10745
+ );
10746
const resumeSessionAt = yield* getNativeConversationHeadId(turnInput.providerThread);
10747
const existing = yield* Ref.get(queryContext);
10748
// Continuations drain existing output without prompting; retain the live process regardless of selection.
@@ -10852,6 +10857,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
10857
);
10858
const queryOptions = makeClaudeQueryOptions({
10859
modelSelection: turnInput.modelSelection,
10860
+ modelCatalog,
10861
nativeThreadId,
10862
title: turnInput.appThread.title,
10863
resume: shouldResume,
@@ -11099,7 +11105,8 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
11105
: yield* makeClaudeUserMessageWithAttachments({
11106
text: applyClaudePromptEffortPrefix(
11107
turnInput.message.text,
11102
- compileClaudeModelSelection(turnInput.modelSelection).promptEffort,
11108
+ compileClaudeModelSelection(turnInput.modelSelection, modelCatalog)
11109
+ .promptEffort,
11110
),
11111
attachments: turnInput.message.attachments,
11112
attachmentsDir,
@@ -11548,7 +11555,8 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
11555
const userMessage = yield* makeClaudeUserMessageWithAttachments({
11556
text: applyClaudePromptEffortPrefix(
11557
turnInput.message.text,
11551
- compileClaudeModelSelection(currentTurn.input.modelSelection).promptEffort,
11558
+ compileClaudeModelSelection(currentTurn.input.modelSelection, modelCatalog)
11559
+ .promptEffort,
11560
),
11561
attachments: turnInput.message.attachments,
11562
priority: "now",
apps/server/src/provider/ClaudeModelCatalog.test.ts
+8
@@ -4,6 +4,7 @@ import { ProviderDriverKind, ProviderInstanceId } from "@t3tools/contracts";
4
import { resolveProviderCatalog, type ModelManifestData } from "./ModelManifest.ts";
5
import {
6
formatClaudeVersionUpgradeMessage,
7
+ getClaudeCatalogModelCapabilities,
8
normalizeClaudeCatalogEffort,
9
resolveClaudeCatalogApiModelId,
10
resolveClaudeCatalogContextWindowTokens,
@@ -185,6 +186,7 @@ describe("Claude model catalog", () => {
186
options: [
187
{ id: "gentle", label: "Gentle", isDefault: true },
188
{ id: "brutal", label: "Brutal" },
189
+ { id: "ultracode", label: "Ultracode" },
190
],
191
},
192
],
@@ -205,6 +207,12 @@ describe("Claude model catalog", () => {
207
resolveClaudeCatalogEffort(catalog, "claude-custom-tuned", "bogus"),
208
"gentle",
209
);
210
+ assert.deepStrictEqual(
211
+ getClaudeCatalogModelCapabilities(catalog, "claude-custom-tuned").optionDescriptors?.map(
212
+ ({ id, type }) => `${id}:${type}`,
213
+ ),
214
+ ["effort:select", "ultracode:boolean"],
215
+ );
216
assert.strictEqual(
217
normalizeClaudeCatalogEffort(catalog, "brutal", "claude-custom-tuned"),
218
"brutal",
apps/server/src/provider/ClaudeModelCatalog.ts
+48
-6
@@ -48,8 +48,9 @@ function tryResolveClaudeModelCatalog(
48
const profile = decodeClaudeProfileAdapter(entry.profileAdapter ?? {});
49
const adapter = decodeClaudeModelAdapter(entry.adapter ?? {});
50
if (Option.isNone(profile) || Option.isNone(adapter)) return null;
51
+ const model = ModelCatalog.catalogServerModel(resolved, entry);
52
models.push({
52
- model: ModelCatalog.catalogServerModel(resolved, entry),
53
+ model: { ...model, capabilities: withUltracodeToggle(model.capabilities) },
54
runtime: profile.value.claudeCode ?? {},
55
compatibility: adapter.value.claudeCode ?? {},
56
});
@@ -60,6 +61,51 @@ function tryResolveClaudeModelCatalog(
61
};
62
}
63
64
+// The manifest keeps Ultracode as an effort level because released servers read it from main.
65
+export function withUltracodeToggle(
66
+ capabilities: ModelCapabilities | null,
67
+): ModelCapabilities | null {
68
+ const descriptors = capabilities?.optionDescriptors ?? [];
69
+ const effortIndex = descriptors.findIndex(
70
+ (descriptor) =>
71
+ descriptor.id === "effort" &&
72
+ descriptor.type === "select" &&
73
+ descriptor.options.some((option) => option.id === "ultracode"),
74
+ );
75
+ const effort = descriptors[effortIndex];
76
+ if (effort?.type !== "select") return capabilities;
77
+ const ultracodeByDefault =
78
+ (effort.currentValue ?? effort.options.find((option) => option.isDefault)?.id) === "ultracode";
79
+ const hasXhigh = effort.options.some((option) => option.id === "xhigh");
80
+ // Ultracode ran at xhigh, so a model that offered it keeps xhigh, and its default moves there.
81
+ const options = effort.options.flatMap(({ isDefault, ...option }) => {
82
+ if (option.id === "ultracode") {
83
+ return hasXhigh
84
+ ? []
85
+ : [{ id: "xhigh", label: "Extra High", ...(isDefault ? { isDefault } : {}) }];
86
+ }
87
+ if (ultracodeByDefault && option.id === "xhigh") return [{ ...option, isDefault: true }];
88
+ return [isDefault && !ultracodeByDefault ? { ...option, isDefault } : option];
89
+ });
90
+ return {
91
+ optionDescriptors: descriptors.toSpliced(
92
+ effortIndex,
93
+ 1,
94
+ {
95
+ ...effort,
96
+ ...(effort.currentValue === "ultracode" ? { currentValue: "xhigh" } : {}),
97
+ options,
98
+ },
99
+ {
100
+ id: "ultracode",
101
+ label: "Ultracode",
102
+ type: "boolean",
103
+ ...(ultracodeByDefault ? { currentValue: true } : {}),
104
+ },
105
+ ),
106
+ };
107
+}
108
+
109
/** Resolve the fallback on each read so its new-model badges can expire. */
110
export function resolveClaudeModelCatalog(
111
catalog: ModelCatalog.ProviderCatalog | undefined,
@@ -105,7 +151,7 @@ export function scopeClaudeModelCatalog(
151
slug: entry.slug,
152
name: entry.name,
153
isCustom: true,
108
- capabilities: entry.capabilities,
154
+ capabilities: withUltracodeToggle(entry.capabilities),
155
},
156
runtime: {},
157
compatibility: {},
@@ -296,10 +342,6 @@ export function normalizeClaudeCatalogEffort(
342
return effortMap[effort] ?? undefined;
343
}
344
299
-export function isClaudeCatalogUltracodeEffort(effort: string | null | undefined): boolean {
300
- return effort === "ultracode";
301
-}
302
-
345
function resolveClaudeCatalogContextWindow(
346
catalog: ClaudeModelCatalog,
347
modelSelection: ModelSelection | undefined,
apps/server/src/provider/ClaudeProvider.ts
+18
-6
@@ -2,6 +2,7 @@ import {
2
type ClaudeSettings,
3
type ModelCapabilities,
4
type ServerProvider,
5
+ type ServerProviderModel,
6
type ServerProviderSlashCommand,
7
type ServerProviderResetCredits,
8
} from "@t3tools/contracts";
@@ -54,12 +55,26 @@ import {
55
formatClaudeVersionUpgradeMessage,
56
resolveClaudeModelsForVersion,
57
resolveClaudeUpdateRequiredModels,
58
+ withUltracodeToggle,
59
} from "./ClaudeModelCatalog.ts";
60
61
const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({
62
optionDescriptors: [],
63
});
64
65
+function claudeProviderModels(
66
+ builtInModels: ReadonlyArray<ServerProviderModel>,
67
+ customModels: ClaudeSettings["customModels"],
68
+): ReadonlyArray<ServerProviderModel> {
69
+ return providerModelsFromSettings(
70
+ builtInModels,
71
+ customModels,
72
+ DEFAULT_CLAUDE_MODEL_CAPABILITIES,
73
+ ).map((model) =>
74
+ model.isCustom ? { ...model, capabilities: withUltracodeToggle(model.capabilities) } : model,
75
+ );
76
+}
77
+
78
const CLAUDE_PRESENTATION = {
79
displayName: "Claude",
80
showInteractionModeToggle: true,
@@ -513,10 +528,9 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
528
> {
529
const resolvedEnvironment = environment ?? process.env;
530
const checkedAt = DateTime.formatIso(yield* DateTime.now);
516
- const allModels = providerModelsFromSettings(
531
+ const allModels = claudeProviderModels(
532
modelCatalog.models.map((entry) => entry.model),
533
claudeSettings.customModels,
519
- DEFAULT_CLAUDE_MODEL_CAPABILITIES,
534
);
535
536
if (!claudeSettings.enabled) {
@@ -614,13 +628,12 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
628
probeResult && Result.isSuccess(probeResult) ? probeResult.success : undefined;
629
const probeFailure =
630
probeResult && Result.isFailure(probeResult) ? probeResult.failure : undefined;
617
- const models = providerModelsFromSettings(
631
+ const models = claudeProviderModels(
632
[
633
...resolveClaudeModelsForVersion(modelCatalog, parsedVersion),
634
...claudeReportedModels(modelCatalog, claudeSettings.customModels, capabilities?.models),
635
],
636
claudeSettings.customModels,
623
- DEFAULT_CLAUDE_MODEL_CAPABILITIES,
637
);
638
const skills = yield* discoverClaudeSkills(claudeSettings, cwd, resolvedEnvironment);
639
const slashCommands = [COMPACT_SLASH_COMMAND, ...(capabilities?.slashCommands ?? [])];
@@ -737,10 +750,9 @@ export const makePendingClaudeProvider = Effect.fn("ClaudeProvider.makePendingCl
750
modelCatalog: ClaudeModelCatalog = BUNDLED_CLAUDE_MODEL_CATALOG,
751
): Effect.fn.Return<ServerProviderDraft> {
752
const checkedAt = yield* nowIso;
740
- const models = providerModelsFromSettings(
753
+ const models = claudeProviderModels(
754
modelCatalog.models.map((entry) => entry.model),
755
claudeSettings.customModels,
743
- DEFAULT_CLAUDE_MODEL_CAPABILITIES,
756
);
757
758
if (!claudeSettings.enabled) {
apps/server/src/provider/ProviderRegistry.test.ts
+46
@@ -3344,5 +3344,51 @@ it.layer(
3344
),
3345
),
3346
);
3347
+
3348
+ it.effect("advertises Ultracode as a toggle on custom models", () =>
3349
+ Effect.gen(function* () {
3350
+ const status = yield* checkClaudeProviderStatus(
3351
+ {
3352
+ ...defaultClaudeSettings,
3353
+ customModels: [
3354
+ {
3355
+ slug: "claude-custom-tuned",
3356
+ capabilities: {
3357
+ optionDescriptors: [
3358
+ {
3359
+ id: "effort",
3360
+ label: "Reasoning",
3361
+ type: "select",
3362
+ options: [
3363
+ { id: "high", label: "High", isDefault: true },
3364
+ { id: "ultracode", label: "Ultracode" },
3365
+ ],
3366
+ },
3367
+ ],
3368
+ },
3369
+ },
3370
+ ],
3371
+ },
3372
+ claudeCapabilities(),
3373
+ );
3374
+ const custom = status.models.find((model) => model.slug === "claude-custom-tuned");
3375
+ assert.deepStrictEqual(
3376
+ custom?.capabilities?.optionDescriptors?.map((descriptor) =>
3377
+ descriptor.type === "select"
3378
+ ? `${descriptor.id}:${descriptor.options.map((option) => option.id).join("|")}`
3379
+ : `${descriptor.id}:${descriptor.type}`,
3380
+ ),
3381
+ ["effort:high|xhigh", "ultracode:boolean"],
3382
+ );
3383
+ }).pipe(
3384
+ Effect.provide(
3385
+ layerMockSpawner((args) => {
3386
+ const joined = args.join(" ");
3387
+ if (joined === "--version") return { stdout: "1.0.0\n", stderr: "", code: 0 };
3388
+ throw new Error(`Unexpected args: ${joined}`);
3389
+ }),
3390
+ ),
3391
+ ),
3392
+ );
3393
});
3394
});
apps/server/src/textGeneration/ClaudeTextGeneration.ts
+2
-3
@@ -22,7 +22,6 @@ import {
22
BUNDLED_CLAUDE_MODEL_CATALOG,
23
type ClaudeModelCatalog,
24
getClaudeCatalogModelCapabilities,
25
- isClaudeCatalogUltracodeEffort,
25
normalizeClaudeCatalogEffort,
26
resolveClaudeCatalogApiModelId,
27
resolveClaudeCatalogEffort,
@@ -163,7 +162,7 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
162
resolvedEffort,
163
resolvedModelSelection.model,
164
);
166
- const ultracode = isClaudeCatalogUltracodeEffort(resolvedEffort);
165
+ const ultracode = findDescriptor("ultracode")?.currentValue;
166
const thinkingDescriptor = findDescriptor("thinking");
167
const fastModeDescriptor = findDescriptor("fastMode");
168
// Only a chosen value; otherwise Claude Code's own default applies, as in chat turns.
@@ -177,7 +176,7 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
176
disableAllHooks: true,
177
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
178
...(fastMode ? { fastMode: true } : {}),
180
- ...(ultracode ? { ultracode: true } : {}),
179
+ ...(typeof ultracode === "boolean" ? { ultracode } : {}),
180
};
181
const settingsJson = yield* encodeJsonForOperation(
182
operation,
apps/web/src/components/chat/ComposerModelEffort.tsx
+40
-5
@@ -7,7 +7,7 @@ import {
7
import type { ProviderOptionDescriptor, RuntimeMode } from "@t3tools/contracts";
8
import type { EffortDisplay } from "@t3tools/contracts/settings";
9
import { getProviderOptionCurrentLabel } from "@t3tools/shared/model";
10
-import { CheckIcon, ChevronRightIcon, ChevronUpIcon } from "lucide-react";
10
+import { CheckIcon, ChevronRightIcon, ChevronUpIcon, WorkflowIcon } from "lucide-react";
11
import { type KeyboardEvent, type ReactNode, use, useRef, useState } from "react";
12
13
import { cn } from "~/lib/utils";
@@ -36,7 +36,7 @@ import {
36
type SelectDescriptor = Extract<ProviderOptionDescriptor, { type: "select" }>;
37
type BooleanDescriptor = Extract<ProviderOptionDescriptor, { type: "boolean" }>;
38
39
-/** Codex service tiers and Claude's Fast mode share the footer's speed control. */
39
+/** Codex service tiers, Claude's Fast mode, and Ultracode sit in the footer, not the column. */
40
function splitSpeed(
41
provider: TraitsSelectionInput["provider"],
42
selects: ReadonlyArray<SelectDescriptor>,
@@ -47,11 +47,15 @@ function splitSpeed(
47
? (selects.find((descriptor) => descriptor.id === "serviceTier") ?? null)
48
: null;
49
const fastToggle = toggles.find((descriptor) => descriptor.id === "fastMode") ?? null;
50
+ const ultracodeToggle = toggles.find((descriptor) => descriptor.id === "ultracode") ?? null;
51
return {
52
speedSelect,
53
fastToggle,
54
+ ultracodeToggle,
55
columnSelects: selects.filter((descriptor) => descriptor !== speedSelect),
54
- columnToggles: toggles.filter((descriptor) => descriptor !== fastToggle),
56
+ columnToggles: toggles.filter(
57
+ (descriptor) => descriptor !== fastToggle && descriptor !== ultracodeToggle,
58
+ ),
59
};
60
}
61
@@ -79,7 +83,8 @@ function columnControls(
83
84
/**
85
* What the model trigger shows after the model name: the effort word (or bars, per the
82
- * Appearance setting), a bolt for Fast, and other traits such as a context window.
86
+ * Appearance setting), a bolt for Fast, a workflow icon for Ultracode, and other traits such as a
87
+ * context window.
88
*/
89
export function describeComposerEffort(
90
traits: TraitsSelectionInput | null,
@@ -135,7 +140,8 @@ export function describeComposerEffort(
140
modelSelection,
141
traits.reportedModelSelection,
142
);
138
- if (!word && !glyph && !fast && !contextWindow) return { suffix: null, detail: display.label };
143
+ if (!word && !glyph && !fast && !display.ultracode && !contextWindow)
144
+ return { suffix: null, detail: display.label };
145
return {
146
detail: display.label,
147
suffix: (
@@ -154,6 +160,9 @@ export function describeComposerEffort(
160
<EffortGlyph count={glyph.count} filled={glyph.filled} size={size} />
161
) : null}
162
{fast ? <FastBolt ultra={display.speedLabel === "Ultrafast"} /> : null}
163
+ {display.ultracode ? (
164
+ <WorkflowIcon aria-hidden="true" data-composer-control-icon className="size-3" />
165
+ ) : null}
166
{contextWindow ? (
167
<span
168
// A label, so icon-only footers drop it; compacted rows drop it before the model.
@@ -595,6 +604,31 @@ function SpeedControl(props: { traits: TraitsSelectionInput }) {
604
);
605
}
606
607
+function UltracodeControl(props: { traits: TraitsSelectionInput }) {
608
+ const traits = useTraitsSelection(props.traits);
609
+ const { ultracodeToggle } = splitSpeed(
610
+ props.traits.provider,
611
+ traits.selectDescriptors,
612
+ traits.booleanDescriptors,
613
+ );
614
+ if (traits.modelIsUnavailable || !ultracodeToggle) return null;
615
+ const on = ultracodeToggle.currentValue === true;
616
+ return (
617
+ <div className="flex rounded-lg bg-input/40 p-0.5">
618
+ <button
619
+ type="button"
620
+ aria-pressed={on}
621
+ data-checked={on || undefined}
622
+ className={FOOTER_SEGMENT}
623
+ onClick={() => traits.changeBoolean(ultracodeToggle.id, !on)}
624
+ >
625
+ <WorkflowIcon aria-hidden="true" className="size-3" />
626
+ {ultracodeToggle.label}
627
+ </button>
628
+ </div>
629
+ );
630
+}
631
+
632
/** Permissions change rarely, so the footer names the mode and nests the choice in a menu. */
633
function PermissionsMenu(props: {
634
runtimeMode: RuntimeMode;
@@ -647,6 +681,7 @@ export function ComposerPickerFooter(props: {
681
return (
682
<div className="flex flex-wrap items-center gap-2 border-t border-border/70 bg-muted/40 px-3 py-2">
683
{props.traits ? <SpeedControl traits={props.traits} /> : null}
684
+ {props.traits ? <UltracodeControl traits={props.traits} /> : null}
685
<PermissionsMenu
686
runtimeMode={props.runtimeMode}
687
options={props.runtimeModeOptions}
apps/web/src/components/chat/EffortGlyph.tsx
+1
-1
@@ -10,7 +10,7 @@ const BASELINE_INSET = 2;
10
11
type SelectDescriptor = Extract<ProviderOptionDescriptor, { type: "select" }>;
12
13
-// Ultracode changes the workflow, not only intensity, so it keeps its name like Ultrathink.
13
+// Older servers offer Ultracode as a level. It changes the workflow, so it keeps its name.
14
// Max is named too, so the full scale stops short of it.
15
const NAMED_LEVELS = new Set(["ultracode", "max"]);
16
const OFF_LEVELS = new Set(["off", "none"]);
apps/web/src/components/chat/SubagentTooltipContent.tsx
+8
-8
@@ -50,16 +50,16 @@ export function SubagentTooltipContent(props: {
50
result?: string | null | undefined;
51
progress?: string | null | undefined;
52
}) {
53
- const { modelLabel, workspace: metadata } = resolveSubagentMetadata(props);
54
- const preview = subagentDetailPreview(props);
55
- const model = props.model?.trim();
56
- const modelSlug = props.provider
57
- ? resolveSelectableModel(props.provider.driver, model, props.provider.models)
58
- : model;
59
- const providerModel = props.provider?.models.find((candidate) => candidate.slug === modelSlug);
53
const childSelection =
54
props.modelSelection ??
55
(props.origin === "app_owned" ? props.childThread?.modelSelection : undefined);
56
+ const {
57
+ modelLabel,
58
+ modelSlug,
59
+ workspace: metadata,
60
+ } = resolveSubagentMetadata({ ...props, modelSelection: childSelection });
61
+ const preview = subagentDetailPreview(props);
62
+ const providerModel = props.provider?.models.find((candidate) => candidate.slug === modelSlug);
63
const childModel = props.provider
64
? (resolveSelectableModel(
65
props.provider.driver,
@@ -69,7 +69,7 @@ export function SubagentTooltipContent(props: {
69
: childSelection?.model.trim();
70
const provider = props.provider;
71
const matchingSelection =
72
- childModel === (modelSlug ?? model) && childSelection?.instanceId === props.providerInstanceId
72
+ childModel === modelSlug && childSelection?.instanceId === props.providerInstanceId
73
? childSelection
74
: undefined;
75
const effort = REASONING_EFFORT_OPTION_IDS.map((id) =>
apps/web/src/components/chat/ThreadLineageWorkflowRow.tsx
+5
-3
@@ -1,6 +1,7 @@
1
-import type {
2
- SubagentWorkflowGroup,
3
- RuntimeSubagent,
1
+import {
2
+ workflowMemberModelSelection,
3
+ type SubagentWorkflowGroup,
4
+ type RuntimeSubagent,
5
} from "@t3tools/client-runtime/state/subagentRuntime";
6
import type { ProviderDriverKind, ProviderInstanceId, ServerProvider } from "@t3tools/contracts";
7
import { ChevronDownIcon, SquareIcon } from "lucide-react";
@@ -101,6 +102,7 @@ function WorkflowMemberRow({
102
model={member.model}
103
providerInstanceId={providerInstanceId}
104
origin="provider_native"
105
+ modelSelection={workflowMemberModelSelection(member, providerInstanceId)}
106
provider={provider}
107
providers={providers}
108
driver={driver}
apps/web/src/components/chat/WorkflowOpeningBlock.tsx
+2
@@ -1,6 +1,7 @@
1
import { useAtomValue } from "@effect/atom-react";
2
import {
3
isTerminalSubagentStatus,
4
+ workflowMemberModelSelection,
5
workflowOpeningHeadline,
6
type RuntimeSubagent,
7
type WorkflowOpening,
@@ -183,6 +184,7 @@ function WorkflowMemberRow(props: {
184
model={member.model}
185
providerInstanceId={props.providerInstanceId}
186
origin="provider_native"
187
+ modelSelection={workflowMemberModelSelection(member, props.providerInstanceId)}
188
provider={props.providers.find(
189
(provider) => provider.instanceId === props.providerInstanceId,
190
)}
packages/client-runtime/src/modelTraits.ts
+12
-2
@@ -120,10 +120,12 @@ export function buildTraitsTriggerDisplay(input: {
120
label: string;
121
/** "Fast" or "Ultrafast" when a speed option is on. */
122
speedLabel: string | null;
123
+ ultracode: boolean;
124
} {
125
let fastModeFallbackLabel: string | null = null;
126
let speedLabel: string | null = null;
127
let reasoningLabelIndex = -1;
128
+ let ultracodeLabelIndex = -1;
129
const labels: Array<string> = [];
130
for (const descriptor of input.descriptors) {
131
if (descriptor.id === "fastMode" && descriptor.type === "boolean") {
@@ -131,6 +133,13 @@ export function buildTraitsTriggerDisplay(input: {
133
fastModeFallbackLabel = speedLabel ?? "Normal";
134
continue;
135
}
136
+ if (descriptor.id === "ultracode" && descriptor.type === "boolean") {
137
+ if (descriptor.currentValue === true) {
138
+ ultracodeLabelIndex = labels.length;
139
+ labels.push(descriptor.label);
140
+ }
141
+ continue;
142
+ }
143
if (
144
input.provider === "codex" &&
145
descriptor.id === "serviceTier" &&
@@ -173,8 +182,9 @@ export function buildTraitsTriggerDisplay(input: {
182
}
183
}
184
185
+ const ultracode = ultracodeLabelIndex >= 0;
186
if (labels.length === 0 && fastModeFallbackLabel !== null) {
177
- return { label: fastModeFallbackLabel, speedLabel };
187
+ return { label: fastModeFallbackLabel, speedLabel, ultracode };
188
}
189
if (speedLabel) {
190
if (reasoningLabelIndex >= 0) {
@@ -183,5 +193,5 @@ export function buildTraitsTriggerDisplay(input: {
193
labels.push(speedLabel);
194
}
195
}
186
- return { label: labels.join(" · "), speedLabel };
196
+ return { label: labels.join(" · "), speedLabel, ultracode };
197
}
packages/client-runtime/src/state/subagentDisplay.ts
+4
-2
@@ -1,4 +1,5 @@
1
import type {
2
+ ModelSelection,
3
OrchestrationV2TurnItemStatus,
4
OrchestrationV2ThreadShell,
5
OrchestrationProjectShell,
@@ -50,6 +51,7 @@ export function formatSubagentDisplayTitle(title: string): string {
51
52
export function resolveSubagentMetadata(input: {
53
readonly model: string | null;
54
+ readonly modelSelection?: Pick<ModelSelection, "model"> | undefined;
55
readonly provider?: Pick<ServerProvider, "driver" | "models"> | null | undefined;
56
readonly parentThread?:
57
| Pick<OrchestrationV2ThreadShell, "projectId" | "worktreePath">
@@ -65,7 +67,7 @@ export function resolveSubagentMetadata(input: {
67
| null
68
| undefined;
69
}) {
68
- const model = input.model?.trim();
70
+ const model = input.model?.trim() || input.modelSelection?.model.trim();
71
const slug = input.provider
72
? resolveSelectableModel(input.provider.driver, model, input.provider.models)
73
: model;
@@ -108,7 +110,7 @@ export function resolveSubagentMetadata(input: {
110
]
111
: []),
112
];
111
- return { modelLabel, workspace };
113
+ return { modelLabel, modelSlug: slug ?? model ?? null, workspace };
114
}
115
116
export function subagentDetailPreview(input: {
packages/client-runtime/src/state/subagentRuntime.test.ts
+39
@@ -13,7 +13,10 @@ import {
13
isWorkflowScriptMessage,
14
projectedSubagentsToRuntime,
15
resolveWorkflowOpening,
16
+ workflowMemberModelSelection,
17
} from "./subagentRuntime.ts";
18
+import { resolveSubagentMetadata } from "./subagentDisplay.ts";
19
+import { formatSubagentEffort } from "./threadExecution.ts";
20
21
const at = (iso: string) => DateTime.makeUnsafe(iso);
22
@@ -82,6 +85,42 @@ describe("projectedSubagentsToRuntime workflow expansion", () => {
85
expect(settled?.speed).toBe("standard");
86
expect(settled?.progress).toBe("Reply with exactly: A1");
87
expect(settled?.usage).toEqual({ totalTokens: 71_141, toolUses: 3, durationMs: 1500 });
88
+ const instanceId = ProviderInstanceId.make("claudeAgent");
89
+ expect(workflowMemberModelSelection(settled!, instanceId)).toEqual({
90
+ instanceId,
91
+ model: "claude-opus-5[1m]",
92
+ options: [
93
+ { id: "effort", value: "xhigh" },
94
+ { id: "fastMode", value: false },
95
+ ],
96
+ });
97
+ expect(workflowMemberModelSelection({ model: null, effort: "xhigh" }, instanceId)).toBe(
98
+ undefined,
99
+ );
100
+ const provider = {
101
+ driver: ProviderDriverKind.make("claudeAgent"),
102
+ models: [
103
+ { slug: "claude-opus-5", name: "Claude Opus 5", isCustom: false, capabilities: null },
104
+ ],
105
+ };
106
+ const modelSelection = workflowMemberModelSelection(settled!, instanceId);
107
+ const { modelSlug } = resolveSubagentMetadata({
108
+ model: settled!.model,
109
+ modelSelection,
110
+ provider,
111
+ });
112
+ expect(formatSubagentEffort({ modelSlug, modelSelection, provider })).toBe("xhigh");
113
+ });
114
+
115
+ it("names a workflow by the model it runs on when the provider reports none", () => {
116
+ const [workflow] = projectedSubagentsToRuntime([subagent({ model: null })]);
117
+ expect(
118
+ resolveSubagentMetadata({
119
+ model: workflow!.model,
120
+ modelSelection: { model: "claude-opus-5-5" },
121
+ }).modelLabel,
122
+ ).toBe("Claude Opus 5.5");
123
+ expect(resolveSubagentMetadata({ model: workflow!.model }).modelLabel).toBe("Not reported");
124
});
125
126
it.each(["completed", "cancelled", "failed"] as const)(
packages/client-runtime/src/state/subagentRuntime.ts
+16
@@ -1,6 +1,7 @@
1
import { groupBy } from "effect/Array";
2
import * as DateTime from "effect/DateTime";
3
import type {
4
+ ModelSelection,
5
OrchestrationV2AppThread,
6
OrchestrationV2Subagent,
7
OrchestrationV2SubagentWorkflow,
@@ -175,6 +176,21 @@ function workflowMembersToRuntime(
176
});
177
}
178
179
+export function workflowMemberModelSelection(
180
+ member: Pick<RuntimeSubagent, "model" | "effort" | "speed">,
181
+ instanceId: ModelSelection["instanceId"],
182
+): ModelSelection | undefined {
183
+ if (!member.model) return undefined;
184
+ return {
185
+ instanceId,
186
+ model: member.model,
187
+ options: [
188
+ ...(member.effort ? [{ id: "effort", value: member.effort }] : []),
189
+ ...(member.speed ? [{ id: "fastMode", value: member.speed === "fast" }] : []),
190
+ ],
191
+ };
192
+}
193
+
194
export function projectedSubagentsToRuntime(
195
subagents: ReadonlyArray<{
196
readonly id: string;
packages/client-runtime/src/state/threadExecution.test.ts
+35
@@ -14,6 +14,7 @@ import {
14
type OrchestrationV2RunStatus,
15
} from "@t3tools/contracts";
16
import * as DateTime from "effect/DateTime";
17
+import { createModelCapabilities, createModelSelection } from "@t3tools/shared/model";
18
import { usageLimitBlockedRun } from "@t3tools/shared/orchestrationV2ThreadError";
19
import { describe, expect, it } from "vite-plus/test";
20
@@ -26,6 +27,7 @@ import {
27
deriveRunlessWorkStartedAt,
28
deriveThreadActivityRun,
29
deriveThreadRuntime,
30
+ formatModelSelectionEffort,
31
isBackgroundWorkStopPending,
32
presentPendingBackgroundWork,
33
presentProviderGoal,
@@ -473,6 +475,39 @@ describe("provider-reported model selection", () => {
475
});
476
});
477
478
+describe("formatModelSelectionEffort", () => {
479
+ it("labels an old Ultracode effort by the effort it runs at", () => {
480
+ const models = [
481
+ {
482
+ slug: "claude-opus-5-5",
483
+ name: "Claude Opus 5.5",
484
+ isCustom: false,
485
+ capabilities: createModelCapabilities({
486
+ optionDescriptors: [
487
+ {
488
+ id: "effort",
489
+ label: "Reasoning",
490
+ type: "select",
491
+ options: [
492
+ { id: "high", label: "High", isDefault: true },
493
+ { id: "xhigh", label: "Extra High" },
494
+ ],
495
+ },
496
+ { id: "ultracode", label: "Ultracode", type: "boolean" },
497
+ ],
498
+ }),
499
+ },
500
+ ];
501
+ const selection = createModelSelection(
502
+ ProviderInstanceId.make("claudeAgent"),
503
+ "claude-opus-5-5",
504
+ [{ id: "effort", value: "ultracode" }],
505
+ );
506
+
507
+ expect(formatModelSelectionEffort(selection, models)).toBe("Extra High");
508
+ });
509
+});
510
+
511
describe("isBackgroundWorkStopPending", () => {
512
const tasks = [{ taskId: "dev-server" }];
513
const sent = { threadKey: "env:thread", taskIds: ["dev-server"], retryAt: null };
packages/client-runtime/src/state/threadExecution.ts
+34
-3
@@ -13,6 +13,7 @@ import {
13
type OrchestrationV2NotificationSource,
14
type OrchestrationV2PendingBackgroundTask,
15
type OrchestrationV2ProviderGoal,
16
+ type ServerProvider,
17
type ServerProviderModel,
18
type OrchestrationV2ExecutionNode,
19
type OrchestrationV2ThreadProjection,
@@ -24,7 +25,13 @@ import {
25
backgroundWorkHoldsCompletion,
26
derivePendingBackgroundWork,
27
} from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
27
-import { getProviderOptionCurrentLabel, getProviderOptionStatedValue } from "@t3tools/shared/model";
28
+import {
29
+ getModelSelectionStringOptionValue,
30
+ getProviderOptionCurrentLabel,
31
+ getProviderOptionStatedValue,
32
+ resolveSelectableModel,
33
+ withLegacyUltracodeEffort,
34
+} from "@t3tools/shared/model";
35
import { formatDuration } from "@t3tools/shared/orchestrationTiming";
36
import * as DateTime from "effect/DateTime";
37
@@ -164,16 +171,18 @@ export function formatModelSelectionEffort(
171
): string | null {
172
const caps = models.find((model) => model.slug === selection.model)?.capabilities;
173
if (!caps) return null;
174
+ const options = withLegacyUltracodeEffort(caps.optionDescriptors, selection.options);
175
+ const current = options ? { ...selection, options } : selection;
176
for (const id of REASONING_EFFORT_OPTION_IDS) {
177
const descriptor = caps.optionDescriptors?.find((candidate) => candidate.id === id);
178
if (descriptor?.type !== "select") continue;
170
- const value = getProviderOptionStatedValue(id, selection, reportedSelection);
179
+ const value = getProviderOptionStatedValue(id, current, reportedSelection);
180
if (value === undefined && id !== "variant") continue;
181
if (typeof value === "boolean") continue;
182
// Bypass picker normalization so an obsolete choice cannot become a catalog default.
183
const label = getProviderOptionCurrentLabel(
184
{ ...descriptor, currentValue: value },
176
- selection,
185
+ current,
186
reportedSelection,
187
);
188
if (label) return label;
@@ -181,6 +190,28 @@ export function formatModelSelectionEffort(
190
return null;
191
}
192
193
+/** A reported model the picker catalog does not know, such as `claude-opus-5[1m]`, keeps its raw effort. */
194
+export function formatSubagentEffort(input: {
195
+ readonly modelSlug: string | null;
196
+ readonly modelSelection: ModelSelection | undefined;
197
+ readonly provider: Pick<ServerProvider, "driver" | "models"> | undefined;
198
+}): string | null {
199
+ const { modelSlug, modelSelection: selection, provider } = input;
200
+ if (!provider || !selection || !modelSlug) return null;
201
+ const selectionSlug =
202
+ resolveSelectableModel(provider.driver, selection.model, provider.models) ??
203
+ selection.model.trim();
204
+ if (selectionSlug !== modelSlug) return null;
205
+ if (provider.models.some((model) => model.slug === modelSlug)) {
206
+ return formatModelSelectionEffort({ ...selection, model: modelSlug }, provider.models);
207
+ }
208
+ return (
209
+ REASONING_EFFORT_OPTION_IDS.map((id) => getModelSelectionStringOptionValue(selection, id)).find(
210
+ Boolean,
211
+ ) ?? null
212
+ );
213
+}
214
+
215
const SUBAGENT_STATUS_LABELS: Record<OrchestrationV2ExecutionNode["status"], string> = {
216
idle: "Idle",
217
pending: "Working",
packages/shared/src/model.test.ts
+26
@@ -50,6 +50,32 @@ describe("descriptor helpers", () => {
50
).toEqual([{ id: "fastMode", value: true }]);
51
});
52
53
+ it("dispatches an old Ultracode effort as Extra High with the Ultracode toggle", () => {
54
+ const legacy = [{ id: "effort", value: "ultracode" }];
55
+ const descriptors = getProviderOptionDescriptors({
56
+ caps: createModelCapabilities({
57
+ optionDescriptors: [
58
+ {
59
+ id: "effort",
60
+ label: "Reasoning",
61
+ type: "select",
62
+ options: [
63
+ { id: "high", label: "High", isDefault: true },
64
+ { id: "xhigh", label: "Extra High" },
65
+ ],
66
+ },
67
+ { id: "ultracode", label: "Ultracode", type: "boolean" },
68
+ ],
69
+ }),
70
+ selections: legacy,
71
+ });
72
+
73
+ expect(buildExplicitProviderOptionSelectionsFromDescriptors(descriptors, legacy)).toEqual([
74
+ { id: "effort", value: "xhigh" },
75
+ { id: "ultracode", value: true },
76
+ ]);
77
+ });
78
+
79
it("compares complete model selections independent of option ordering", () => {
80
const left = createModelSelection(ProviderInstanceId.make("codex"), "gpt-5.4", [
81
{ id: "reasoningEffort", value: "high" },
packages/shared/src/model.ts
+32
-2
@@ -196,12 +196,40 @@ function withDescriptorCurrentValue(
196
};
197
}
198
199
+// Ultracode was a Claude effort level before it became its own toggle; that level ran at xhigh.
200
+export function withLegacyUltracodeEffort<
201
+ Selections extends ReadonlyArray<ProviderOptionSelection> | null | undefined,
202
+>(
203
+ descriptors: ReadonlyArray<ProviderOptionDescriptor> | null | undefined,
204
+ selections: Selections,
205
+): Selections | Array<ProviderOptionSelection> {
206
+ if (
207
+ getRawSelectionValueById(selections, "effort") !== "ultracode" ||
208
+ !descriptors?.some(
209
+ (descriptor) => descriptor.id === "ultracode" && descriptor.type === "boolean",
210
+ )
211
+ ) {
212
+ return selections;
213
+ }
214
+ return [
215
+ ...(selections ?? []).map((selection) =>
216
+ selection.id === "effort" && selection.value === "ultracode"
217
+ ? { id: "effort", value: "xhigh" }
218
+ : selection,
219
+ ),
220
+ ...(getRawSelectionValueById(selections, "ultracode") === undefined
221
+ ? [{ id: "ultracode", value: true }]
222
+ : []),
223
+ ];
224
+}
225
+
226
export function getProviderOptionDescriptors(input: {
227
caps: ModelCapabilities;
228
selections?: ReadonlyArray<ProviderOptionSelection> | null | undefined;
229
}): ReadonlyArray<ProviderOptionDescriptor> {
203
- const { caps, selections } = input;
230
+ const { caps } = input;
231
const baseDescriptors = (caps.optionDescriptors ?? []).map(cloneDescriptor);
232
+ const selections = withLegacyUltracodeEffort(baseDescriptors, input.selections);
233
234
return baseDescriptors.map((descriptor) =>
235
withDescriptorCurrentValue(
@@ -312,7 +340,9 @@ export function buildExplicitProviderOptionSelectionsFromDescriptors(
340
if (!selections || selections.length === 0) {
341
return undefined;
342
}
315
- const explicitIds = new Set(selections.map((selection) => selection.id));
343
+ const explicitIds = new Set(
344
+ withLegacyUltracodeEffort(descriptors, selections).map(({ id }) => id),
345
+ );
346
const normalized = buildProviderOptionSelectionsFromDescriptors(descriptors)?.filter(
347
(selection) => explicitIds.has(selection.id),
348
);