Skip to content

Commit 53ef45f

Browse files
fixfonclaudejuliusmarminge
authored
fix(clients): subagent bar stops guessing the subagent's effort (pingdotgg#15710)
Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
1 parent 57f5d84 commit 53ef45f

3 files changed

Lines changed: 54 additions & 13 deletions

File tree

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,43 @@ describe("formatModelSelectionEffort", () => {
464464
},
465465
];
466466

467-
it("shows the model's default effort when the user never picked one", () => {
468-
expect(formatModelSelectionEffort(selection(), catalog({}))).toBe("High");
469-
});
470-
471-
it("names a stored effort the way the catalog does", () => {
467+
it("names stored and matching reported effort, preferring the stored choice", () => {
472468
expect(
473469
formatModelSelectionEffort(selection([{ id: "effort", value: "xhigh" }]), catalog({})),
474470
).toBe("Extra High");
471+
const reported = selection([{ id: "effort", value: "xhigh" }]);
472+
expect(formatModelSelectionEffort(selection(), catalog({}), reported)).toBe("Extra High");
473+
expect(
474+
formatModelSelectionEffort(
475+
selection([{ id: "effort", value: "medium" }]),
476+
catalog({}),
477+
reported,
478+
),
479+
).toBe("Medium");
480+
expect(
481+
formatModelSelectionEffort(
482+
selection([{ id: "effort", value: "retired-effort" }]),
483+
catalog({ currentValue: "medium" }),
484+
reported,
485+
),
486+
).toBeNull();
475487
});
476488

477-
it("uses the descriptor's current value over the default", () => {
478-
expect(formatModelSelectionEffort(selection(), catalog({ currentValue: "medium" }))).toBe(
479-
"Medium",
480-
);
489+
it("shows nothing when neither the selection nor the provider states an effort", () => {
490+
expect(formatModelSelectionEffort(selection(), catalog({}))).toBeNull();
491+
expect(formatModelSelectionEffort(selection(), catalog({ currentValue: "medium" }))).toBeNull();
492+
expect(
493+
formatModelSelectionEffort(selection(), catalog({}), {
494+
...selection([{ id: "effort", value: "xhigh" }]),
495+
model: "claude-opus-5-5",
496+
}),
497+
).toBeNull();
498+
expect(
499+
formatModelSelectionEffort(selection(), catalog({}), {
500+
...selection([{ id: "effort", value: "xhigh" }]),
501+
instanceId: ProviderInstanceId.make("claudeAgent-other"),
502+
}),
503+
).toBeNull();
481504
});
482505

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

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
backgroundWorkHoldsCompletion,
2323
derivePendingBackgroundWork,
2424
} from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
25-
import { getProviderOptionCurrentLabel, getProviderOptionDescriptors } from "@t3tools/shared/model";
25+
import { getProviderOptionCurrentLabel, getProviderOptionStatedValue } from "@t3tools/shared/model";
2626
import { formatDuration } from "@t3tools/shared/orchestrationTiming";
2727
import * as DateTime from "effect/DateTime";
2828

@@ -160,11 +160,18 @@ export function formatModelSelectionEffort(
160160
): string | null {
161161
const caps = models.find((model) => model.slug === selection.model)?.capabilities;
162162
if (!caps) return null;
163-
const descriptors = getProviderOptionDescriptors({ caps, selections: selection.options });
164163
for (const id of REASONING_EFFORT_OPTION_IDS) {
165-
const descriptor = descriptors.find((candidate) => candidate.id === id);
164+
const descriptor = caps.optionDescriptors?.find((candidate) => candidate.id === id);
166165
if (descriptor?.type !== "select") continue;
167-
const label = getProviderOptionCurrentLabel(descriptor, selection, reportedSelection);
166+
const value = getProviderOptionStatedValue(id, selection, reportedSelection);
167+
if (value === undefined && id !== "variant") continue;
168+
if (typeof value === "boolean") continue;
169+
// Bypass picker normalization so an obsolete choice cannot become a catalog default.
170+
const label = getProviderOptionCurrentLabel(
171+
{ ...descriptor, currentValue: value },
172+
selection,
173+
reportedSelection,
174+
);
168175
if (label) return label;
169176
}
170177
return null;

‎packages/shared/src/model.ts‎

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

216+
export function getProviderOptionStatedValue(
217+
id: string,
218+
selection?: ModelSelection | null,
219+
reportedSelection?: ModelSelection | null,
220+
) {
221+
return (
222+
getRawSelectionValueById(selection?.options, id) ??
223+
getReportedOptionValue(id, selection, reportedSelection)
224+
);
225+
}
226+
216227
export function getProviderOptionCurrentValue(
217228
descriptor: ProviderOptionDescriptor | null | undefined,
218229
selection?: ModelSelection | null,

0 commit comments

Comments
 (0)