Skip to content

Commit d133f9d

Browse files
fixfonclaude
andcommitted
fix(clients): subagent bar stops guessing the subagent's effort
A provider-native subagent's thread showed the catalog's default effort ("medium" for an Opus 5.5 subagent that ran at high) whenever its selection carried no effort option, because formatModelSelectionEffort resolved the label the way the composer's picker does: stored choice, else descriptor current value, else catalog default. The adapter writes a subagent's selection from what the provider told it, so a missing option means the effort is unknown. The bar now names an effort only when the selection or a matching provider report states one, and shows nothing otherwise. The composer and the OpenCode "Unknown" placeholder are unchanged. Made by Claude Fable 5.1 in Claude Code. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent a9c9c7c commit d133f9d

4 files changed

Lines changed: 64 additions & 9 deletions

File tree

‎packages/client-runtime/src/state/threadExecution.test.ts‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,33 @@ describe("formatModelSelectionEffort", () => {
434434
},
435435
];
436436

437-
it("shows the model's default effort when the user never picked one", () => {
438-
expect(formatModelSelectionEffort(selection(), catalog({}))).toBe("High");
439-
});
440-
441437
it("names a stored effort the way the catalog does", () => {
442438
expect(
443439
formatModelSelectionEffort(selection([{ id: "effort", value: "xhigh" }]), catalog({})),
444440
).toBe("Extra High");
445441
});
446442

447-
it("uses the descriptor's current value over the default", () => {
448-
expect(formatModelSelectionEffort(selection(), catalog({ currentValue: "medium" }))).toBe(
449-
"Medium",
450-
);
443+
it("names a reported effort when no stored one overrides it", () => {
444+
const reported = selection([{ id: "effort", value: "xhigh" }]);
445+
expect(formatModelSelectionEffort(selection(), catalog({}), reported)).toBe("Extra High");
446+
expect(
447+
formatModelSelectionEffort(
448+
selection([{ id: "effort", value: "medium" }]),
449+
catalog({}),
450+
reported,
451+
),
452+
).toBe("Medium");
453+
});
454+
455+
it("shows nothing when neither the selection nor the provider states an effort", () => {
456+
expect(formatModelSelectionEffort(selection(), catalog({}))).toBeNull();
457+
expect(formatModelSelectionEffort(selection(), catalog({ currentValue: "medium" }))).toBeNull();
458+
expect(
459+
formatModelSelectionEffort(selection(), catalog({}), {
460+
...selection([{ id: "effort", value: "xhigh" }]),
461+
model: "claude-opus-5-5",
462+
}),
463+
).toBeNull();
451464
});
452465

453466
it("shows nothing for a model the catalog does not describe", () => {

‎packages/client-runtime/src/state/threadExecution.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ import {
2121
backgroundWorkHoldsCompletion,
2222
derivePendingBackgroundWork,
2323
} from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
24-
import { getProviderOptionCurrentLabel, getProviderOptionDescriptors } from "@t3tools/shared/model";
24+
import {
25+
getProviderOptionCurrentLabel,
26+
getProviderOptionCurrentValue,
27+
getProviderOptionDescriptors,
28+
isProviderOptionValueStated,
29+
} from "@t3tools/shared/model";
2530
import { formatDuration } from "@t3tools/shared/orchestrationTiming";
2631
import * as DateTime from "effect/DateTime";
2732

@@ -157,6 +162,15 @@ export function formatModelSelectionEffort(
157162
for (const id of REASONING_EFFORT_OPTION_IDS) {
158163
const descriptor = descriptors.find((candidate) => candidate.id === id);
159164
if (descriptor?.type !== "select") continue;
165+
// The adapter writes a subagent's selection from what the provider reported,
166+
// so a missing option is unknown; the catalog's pick is not its effort. A
167+
// resolver with no value at all yields "Unknown", which may still be named.
168+
if (
169+
!isProviderOptionValueStated(id, selection, reportedSelection) &&
170+
getProviderOptionCurrentValue(descriptor, selection, reportedSelection) !== undefined
171+
) {
172+
continue;
173+
}
160174
const label = getProviderOptionCurrentLabel(descriptor, selection, reportedSelection);
161175
if (label) return label;
162176
}

‎packages/shared/src/model.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
formatCodexModelName,
1111
formatModelSlugName,
1212
getProviderOptionCurrentLabel,
13+
isProviderOptionValueStated,
1314
getModelSelectionBooleanOptionValue,
1415
getModelSelectionStringOptionValue,
1516
getProviderOptionDescriptors,
@@ -360,4 +361,19 @@ describe("provider-reported option display", () => {
360361
])("ignores reports after changing the model, instance, or option: %j", (selected) => {
361362
expect(getProviderOptionCurrentLabel(descriptor, selected, reported)).toBe("Unknown");
362363
});
364+
365+
it("tells a stated option from a catalog guess", () => {
366+
expect(isProviderOptionValueStated("variant", selection)).toBe(false);
367+
expect(isProviderOptionValueStated("variant", selection, reported)).toBe(true);
368+
expect(
369+
isProviderOptionValueStated("variant", {
370+
...selection,
371+
options: [{ id: "variant", value: "none" }],
372+
}),
373+
).toBe(true);
374+
expect(isProviderOptionValueStated("variant", { ...selection, model: "other" }, reported)).toBe(
375+
false,
376+
);
377+
expect(isProviderOptionValueStated("effort", selection, reported)).toBe(false);
378+
});
363379
});

‎packages/shared/src/model.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ function getReportedOptionValue(
213213
return getRawSelectionValueById(reportedSelection.options, id);
214214
}
215215

216+
/** A catalog default or current value is a guess, so it does not count as stated. */
217+
export function isProviderOptionValueStated(
218+
id: string,
219+
selection?: ModelSelection | null,
220+
reportedSelection?: ModelSelection | null,
221+
): boolean {
222+
return (
223+
selection?.options?.some((option) => option.id === id) === true ||
224+
getReportedOptionValue(id, selection, reportedSelection) !== undefined
225+
);
226+
}
227+
216228
export function getProviderOptionCurrentValue(
217229
descriptor: ProviderOptionDescriptor | null | undefined,
218230
selection?: ModelSelection | null,

0 commit comments

Comments
 (0)