Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions app/src/lib/models/effort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,23 @@ export function shownPick(
? connectionOf(catalogue, saved.connection)
: undefined;
// A stopped connection's pick is not moved anywhere: its run is refused and the person told so.
if (named && !named.ready && saved?.model)
const stoppedModel = saved?.model || named?.default;
if (named && !named.ready && stoppedModel)
return {
model: saved.model,
effort: saved.effort ?? null,
model: stoppedModel,
effort: saved?.effort ?? null,
connection: named.id,
};
if (named && optionFor(catalogueFor(catalogue, named), saved?.model)) {
/*
* A pick on a connection with no model named is that connection's own default: the server keeps
* a picked model that is its connection's default as null (`ModelChoice`), and runs it there. Shown
* as the default connection's default instead, a pick of Claude Opus on a Claude plan read back as
* a ChatGPT model once the conversation opened, while the run went on Opus.
*/
if (
named &&
(!saved?.model || optionFor(catalogueFor(catalogue, named), saved.model))
) {
const pick = shownPickIn(saved, catalogueFor(catalogue, named));
return pick && { ...pick, connection: named.id };
}
Expand Down
29 changes: 23 additions & 6 deletions app/src/lib/models/run-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ function sayModelNotUsed(bot: AgentProfile) {
* It starts on the catalogue's default. `pickFor` is what `startPicked` (and a start with an `@`)
* asks once the Bot is known: the pick to save with that Bot's conversation, before the first
* message runs, and the line to say once it has started when that Bot takes no pick
* (`takesNoModelChoice`). Nothing to save, and nothing to say, while the pick is the default. A Bot
* that could not be read takes the pick, as `useBotTakesModelChoice` reads it.
* (`takesNoModelChoice`). Nothing to save, and nothing to say, while the pick is the default: the
* Bot's own default runs. Any other pick runs, whatever the Bot's default is. A Bot that could not
* be read takes the pick, as `useBotTakesModelChoice` reads it.
*/
export function usePickedBotModel(
catalogue: ModelCatalogue | undefined,
Expand All @@ -298,15 +299,31 @@ export function usePickedBotModel(
const pickFor = async (
agentId: string,
): Promise<{ pick: ConversationModelInput | null; notUsed?: () => void }> => {
const pick = draft.requested;
if (!pick) return { pick: null };
// On the default (untouched, Auto, or picked by hand), the pick follows the Bot's own default.
const shown = draft.value;
if (!draft.requested || !shown) return { pick: null };
const bot =
roster?.find((agent) => agent.id === agentId) ??
(await queryClient
.fetchQuery(agentQueryOptions(agentId))
.catch(() => undefined));
if (!bot || !(await takesNoModelChoice(queryClient, bot))) return { pick };
return { pick: null, notUsed: () => sayModelNotUsed(bot) };
if (bot && (await takesNoModelChoice(queryClient, bot)))
return { pick: null, notUsed: () => sayModelNotUsed(bot) };
/*
* THE PERSON'S PICK OVER THE BOT'S DEFAULT. What the picker showed is saved as it reads against
* the Bot the message went to. Saved against the catalogue's default instead, a pick of the
* default model at another effort was kept as "the default", and the Bot's own default replaced
* it in that conversation, in the run and in the picker. Against the Bot's default, the default
* model is named outright (`pinModel`), and nothing is saved only for the Bot's default itself.
*/
const request = requestFor(
shown,
catalogue,
offeredBotDefault(bot?.defaultModel, catalogue),
);
return {
pick: request.model === null && request.effort === null ? null : request,
};
};
return { ...draft, pickFor };
}
19 changes: 19 additions & 0 deletions app/tests/model-picker-connections.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,25 @@ test("a model on a connection that isn't the default is saved with its connectio
).toEqual({ model: OPUS.id, effort: "high", connection: "anthropic" });
});

/*
* Reported from dogfooding: the read OpenBot Cloud answered for a pick of Claude Opus 5.5 at Extra
* high on a Claude plan beside a ChatGPT default. The server keeps a model that is its connection's
* own default as null, on that connection, and runs that default there; the picker showed the
* ChatGPT default instead.
*/
test("a pick on a connection that names no model shows that connection's default, which it runs on", () => {
const read = { model: null, effort: "high", connection: "anthropic" };
expect(shownPick(read, TWO)).toEqual({
model: OPUS.id,
effort: "high",
connection: "anthropic",
});
// Saved again as shown, it stays on that connection.
expect(
requestFor(shownPick(read, TWO) as NonNullable<ModelPick>, TWO),
).toEqual({ model: OPUS.id, effort: "high", connection: "anthropic" });
});

test("no default connection: the trigger asks to choose, and a pick still saves", async () => {
const noDefault = catalogueOf([{ ...CHATGPT, isDefault: false }, CLAUDE]);
const picks: ModelPick[] = [];
Expand Down
Loading
Loading