Skip to content

Commit 2d0efd3

Browse files
Bil0000claudejuliusmarminge
authored
feat(claude): Ultracode works with any effort, like Claude Desktop (#27034)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
1 parent 268e581 commit 2d0efd3

27 files changed

Lines changed: 585 additions & 66 deletions

‎apps/mobile/src/features/threads/SubagentRow.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
shouldShowInstanceBadge,
66
} from "@t3tools/client-runtime/state/provider-instance-display";
77
import { resolveSubagentMetadata } from "@t3tools/client-runtime/state/subagent-display";
8+
import { formatSubagentEffort } from "@t3tools/client-runtime/state/thread-execution";
89
import type { EnvironmentId, OrchestrationV2Subagent } from "@t3tools/contracts";
910
import type { ReactNode } from "react";
1011
import { View } from "react-native";
@@ -23,6 +24,7 @@ type SubagentRowSubagent = Pick<
2324
| "threadId"
2425
| "childThreadId"
2526
| "model"
27+
| "modelSelection"
2628
| "driver"
2729
| "providerInstanceId"
2830
| "title"
@@ -132,14 +134,17 @@ function SubagentMetadata(props: {
132134
parent ? scopeProjectRef(environmentId, parent.projectId) : null,
133135
);
134136
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({
136139
model: subagent.model,
140+
modelSelection: selection,
137141
provider,
138142
parentThread: parent,
139143
childThread: child,
140144
parentProject,
141145
childProject,
142146
});
147+
const effort = formatSubagentEffort({ modelSlug, modelSelection: selection, provider });
143148
return (
144149
<View className="min-w-0 flex-row items-center gap-1.5">
145150
{showBadge ? (
@@ -161,6 +166,7 @@ function SubagentMetadata(props: {
161166
<Text className="min-w-0 shrink text-xs text-foreground-muted" numberOfLines={1}>
162167
{provider ? `${resolveProviderInstanceDisplayName(provider)} · ` : ""}
163168
{modelLabel}
169+
{effort ? ` · ${effort}` : ""}
164170
</Text>
165171
{workspace.map(({ label, value }) => (
166172
// Preserve the label against flattening without making it a separate accessibility stop.

‎apps/mobile/src/features/threads/thread-subagent-group.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export function ThreadSubagentGroup(props: {
128128
result: live?.result ?? item.result,
129129
progress: live?.progress ?? item.progress,
130130
model: live?.model ?? null,
131+
modelSelection: live?.modelSelection,
131132
};
132133
});
133134
const grouped = agents.length > 1;

‎apps/mobile/src/features/threads/thread-workflow-opening.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useAtomValue } from "@effect/atom-react";
22
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
33
import {
44
resolveWorkflowOpening,
5+
workflowMemberModelSelection,
56
workflowOpeningHeadline,
67
workflowOpeningParentThreadId,
78
type RuntimeSubagent,
@@ -63,6 +64,7 @@ function memberRowSubagent(
6364
threadId: coordinatorThreadId,
6465
childThreadId: member.childThreadId as ThreadId | null,
6566
model: member.model,
67+
modelSelection: workflowMemberModelSelection(member, opening.providerInstanceId!),
6668
driver: opening.driver!,
6769
providerInstanceId: opening.providerInstanceId!,
6870
title: member.title,

‎apps/server/src/claudeModelOptions.test.ts‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { describe, expect, it } from "@effect/vitest";
33
import { ProviderInstanceId, type ModelSelection } from "@t3tools/contracts";
44

55
import { compileClaudeModelSelection } from "./claudeModelOptions.ts";
6+
import {
7+
BUNDLED_CLAUDE_MODEL_CATALOG,
8+
scopeClaudeModelCatalog,
9+
} from "./provider/ClaudeModelCatalog.ts";
610

711
const selection = (
812
model: string,
@@ -30,6 +34,69 @@ describe("compileClaudeModelSelection", () => {
3034
});
3135
});
3236

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+
33100
it("uses the model default SDK effort alongside prompt-injected effort", () => {
34101
expect(
35102
compileClaudeModelSelection(

‎apps/server/src/claudeModelOptions.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
import {
1010
BUNDLED_CLAUDE_MODEL_CATALOG,
1111
getClaudeCatalogModelCapabilities,
12-
isClaudeCatalogUltracodeEffort,
1312
normalizeClaudeCatalogEffort,
1413
resolveClaudeCatalogApiModelId,
1514
resolveClaudeCatalogEffort,
@@ -29,7 +28,10 @@ export function compileClaudeModelSelection(
2928
catalog: ClaudeModelCatalog = BUNDLED_CLAUDE_MODEL_CATALOG,
3029
): CompiledClaudeModelSelection {
3130
const capabilities = getClaudeCatalogModelCapabilities(catalog, selection.model);
32-
const descriptors = getProviderOptionDescriptors({ caps: capabilities });
31+
const descriptors = getProviderOptionDescriptors({
32+
caps: capabilities,
33+
selections: selection.options,
34+
});
3335
const supportsBoolean = (id: string) =>
3436
descriptors.some((descriptor) => descriptor.type === "boolean" && descriptor.id === id);
3537
const rawEffort = getModelSelectionStringOptionValue(selection, "effort");
@@ -41,10 +43,11 @@ export function compileClaudeModelSelection(
4143
const thinking = supportsBoolean("thinking")
4244
? getModelSelectionBooleanOptionValue(selection, "thinking")
4345
: undefined;
46+
const ultracode = descriptors.find((descriptor) => descriptor.id === "ultracode")?.currentValue;
4447
const settings = {
4548
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
4649
...(typeof fastMode === "boolean" ? { fastMode } : {}),
47-
...(isClaudeCatalogUltracodeEffort(resolvedEffort) ? { ultracode: true } : {}),
50+
...(typeof ultracode === "boolean" ? { ultracode } : {}),
4851
};
4952
const apiModelId = resolveClaudeCatalogApiModelId(catalog, selection);
5053
const promptEffort = resolvePromptInjectedEffort(capabilities, rawEffort) ?? undefined;

‎apps/server/src/mcp/OrchestratorMcpService.test.ts‎

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,6 +3128,18 @@ describe("OrchestratorMcpService provider resolution", () => {
31283128
target: { providerInstanceId: peerId, options: { reasoningEffort: "max" } },
31293129
expected: { instanceId: peerId, model: inherited.model, options: override },
31303130
},
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+
},
31313143
] as const;
31323144
for (const testCase of cases) {
31333145
const commands: Array<unknown> = [];
@@ -3170,12 +3182,33 @@ describe("OrchestratorMcpService provider resolution", () => {
31703182
driver,
31713183
model: inherited.model,
31723184
}),
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+
],
31793212
},
31803213
providerSnapshot({ instanceId: peerId, driver, model: inherited.model }),
31813214
]),

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import {
6666
resolveProjectProviderInstanceEnabled,
6767
SECRET_REQUEST_UNSAVED_NOTE,
6868
} from "@t3tools/contracts";
69-
import { getProviderOptionCurrentValue } from "@t3tools/shared/model";
69+
import { getProviderOptionCurrentValue, withLegacyUltracodeEffort } from "@t3tools/shared/model";
7070
import { runRanAfter } from "@t3tools/shared/orchestrationV2ThreadError";
7171
import { formatThreadLink } from "@t3tools/shared/threadLinks";
7272
import {
@@ -1436,7 +1436,7 @@ const make = Effect.gen(function* () {
14361436

14371437
const descriptors = provider.models.find((candidate) => candidate.slug === model)?.capabilities
14381438
?.optionDescriptors;
1439-
const requestedOptions = input.target?.options;
1439+
const requestedOptions = withLegacyUltracodeEffort(descriptors, input.target?.options);
14401440
if (requestedOptions !== undefined) {
14411441
const invalid = invalidOptionSelections(requestedOptions, descriptors);
14421442
if (invalid.length > 0) {
@@ -1450,7 +1450,10 @@ const make = Effect.gen(function* () {
14501450
const inheritsOptions =
14511451
instanceId === inheritedSelection.instanceId && model === inheritedSelection.model;
14521452
let options = inheritsOptions
1453-
? knownOptions(inheritedSelection.options, descriptors)
1453+
? knownOptions(
1454+
withLegacyUltracodeEffort(descriptors, inheritedSelection.options),
1455+
descriptors,
1456+
)
14541457
: undefined;
14551458
if (requestedOptions !== undefined) {
14561459
const selections = new Map(

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ const CUSTOM_MODEL_CLAUDE_SETTINGS = Schema.decodeSync(ClaudeSettings)({
150150
},
151151
],
152152
});
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+
});
153173
const CLAUDE_TEST_MODEL_SELECTION = {
154174
instanceId: ProviderInstanceId.make(ClaudeAdapterV2.CLAUDE_PROVIDER),
155175
model: "claude-sonnet-4-6",
@@ -5836,7 +5856,8 @@ describe("ClaudeAdapterV2 background wake turns", () => {
58365856
turn(3, {
58375857
...normal,
58385858
options: [
5839-
{ id: "effort", value: "ultracode" },
5859+
{ id: "effort", value: "high" },
5860+
{ id: "ultracode", value: true },
58405861
{ id: "fastMode", value: true },
58415862
],
58425863
}),
@@ -5845,7 +5866,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
58455866
yield* harness.runtime.startTurn(turn(4, { ...normal, model: "claude-sonnet-4-6" }));
58465867
yield* settle;
58475868
assert.deepEqual(harness.liveSelectionChanges, [
5848-
{ effortLevel: "xhigh", fastMode: true, ultracode: true },
5869+
{ effortLevel: "high", fastMode: true, ultracode: true },
58495870
{ model: "claude-sonnet-4-6" },
58505871
{ effortLevel: "high", fastMode: null, ultracode: null },
58515872
]);
@@ -14871,6 +14892,46 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1487114892
),
1487214893
);
1487314894

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+
1487414935
it.effect("resolves a subagent's model and effort against the instance's custom models", () =>
1487514936
Effect.scoped(
1487614937
Effect.gen(function* () {

0 commit comments

Comments
 (0)