Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: sub-agents keep the chat's model

ogsamratba011055329b
diff --git a/apps/app/src/react-app/domains/session/chat/new-task-composer.tsx b/apps/app/src/react-app/domains/session/chat/new-task-composer.tsx
index 2b276416..f38ea00e 100644
--- a/apps/app/src/react-app/domains/session/chat/new-task-composer.tsx
+++ b/apps/app/src/react-app/domains/session/chat/new-task-composer.tsx
@@ -437,7 +437,7 @@ export function NewTaskComposer(props: NewTaskComposerProps) {
runModeControl={<WorkspaceRunModeMenu client={workspaceClient} workspaceId={workspaceId} busy={props.busy} />}
fullPermissionsControl={<FullPermissionsToggle client={workspaceClient} workspaceId={workspaceId} />}
sandboxControl={<SandboxStatusChip client={workspaceClient} workspaceId={workspaceId} onOpenSettings={() => context?.onOpenSettingsSection?.("sandbox")} />}
- subagentModelControl={<SubagentModelMenu client={workspaceClient} />}
+ subagentModelControl={<SubagentModelMenu client={workspaceClient} chatModel={context?.selectedModel?.providerID === "omnirush" ? context.selectedModel.modelID : null} />}
voiceClient={workspaceClient}
voiceWorkspaceId={workspaceId}
draft={props.draft}
diff --git a/apps/app/src/react-app/domains/session/surface/composer/subagent-model-menu.tsx b/apps/app/src/react-app/domains/session/surface/composer/subagent-model-menu.tsx
index 51c48bb6..9f342f5e 100644
--- a/apps/app/src/react-app/domains/session/surface/composer/subagent-model-menu.tsx
+++ b/apps/app/src/react-app/domains/session/surface/composer/subagent-model-menu.tsx
@@ -16,12 +16,11 @@ import {
import { useDesktopRestriction } from "@/react-app/domains/cloud/desktop-config-provider";
import {
SAME_AS_MAIN_LABEL,
- SUBAGENT_MODEL_HELP,
+ SUBAGENT_MODEL_PINNED_HELP,
subagentEffortLabel,
subagentEffortOptions,
- subagentModelName,
- subagentModelUnavailable,
- subagentSummary,
+ subagentPinnedLabel,
+ subagentPinnedSummary,
useSubagentModel,
type SubagentModelClient,
} from "@/react-app/domains/settings/subagent-model";
@@ -31,31 +30,32 @@ const SAME = "__same_as_main__";
export const SUBAGENT_MENU_POLICY_LOCK = "Locked by your organisation: its policy does not allow changing app settings.";
/**
- * The composer's "Sub-agents" menu beside the model selector: the model and
- * effort sub-agents run on (default: the main agent's). Shares its state with
- * Settings > Preferences through useSubagentModel. Hidden until a server
- * client exists and an omnirush.ai account is signed in.
+ * The composer's "Sub-agents" menu beside the model selector. One model per
+ * chat: sub-agents run on the chat's model (`chatModel`, shown, not a
+ * choice); only their effort is set here (default: the main agent's). Shares
+ * its state with Settings > Preferences through useSubagentModel. Hidden
+ * until a server client exists and an omnirush.ai account is signed in.
*/
-export function SubagentModelMenu(props: { client: SubagentModelClient | null }) {
+export function SubagentModelMenu(props: { client: SubagentModelClient | null; chatModel?: string | null }) {
const policyLocked = useDesktopRestriction("allowControlSettings");
if (!props.client) return null;
- return <SubagentModelPicker client={props.client} policyLocked={policyLocked} />;
+ return <SubagentModelPicker client={props.client} chatModel={props.chatModel ?? null} policyLocked={policyLocked} />;
}
-function SubagentModelPicker(props: { client: SubagentModelClient; policyLocked: boolean }) {
+function SubagentModelPicker(props: { client: SubagentModelClient; chatModel: string | null; policyLocked: boolean }) {
const [open, setOpen] = useState(false);
const { state, setting, saving, error, change, refetch } = useSubagentModel(props.client);
if (!state?.signedIn || state.models.length === 0) return null;
- const summary = subagentSummary(state, setting);
- const unavailable = subagentModelUnavailable(state, setting);
- const custom = Boolean(setting.model || setting.effort);
+ const pinned = subagentPinnedLabel(state, props.chatModel);
+ const summary = subagentPinnedSummary(setting.effort);
+ const custom = Boolean(setting.effort);
const locked = props.policyLocked || saving;
- const efforts = subagentEffortOptions(state, setting.model);
+ const efforts = subagentEffortOptions(state, props.chatModel);
- const save = (next: { model?: string | null; effort?: string | null }) => {
+ const save = (next: { effort?: string | null }) => {
if (locked) return;
void change(next)
- .then((saved) => toast.success(`Sub-agents: ${subagentSummary(state, saved)}. Applies to new tasks.`))
+ .then((saved) => toast.success(`Sub-agents: ${subagentPinnedSummary(saved.effort)}. Applies to new tasks.`))
.catch((reason: unknown) => toast.error(reason instanceof Error ? reason.message : "The sub-agent setting could not be saved."));
};
@@ -64,11 +64,11 @@ function SubagentModelPicker(props: { client: SubagentModelClient; policyLocked:
<DropdownMenuTrigger
data-testid="subagent-model-trigger"
aria-label={`Sub-agents: ${summary}`}
- title={props.policyLocked ? SUBAGENT_MENU_POLICY_LOCK : `Sub-agents: ${summary}${unavailable ? " (not available, sub-agents use the main model)" : ""}`}
+ title={props.policyLocked ? SUBAGENT_MENU_POLICY_LOCK : `Sub-agents: ${summary}. ${pinned}.`}
// An icon (the summary in its tooltip) until the composer is wide
// enough for the label, so it never squeezes the model selector.
className={`flex h-9 max-h-9 min-w-9 max-w-64 shrink-[4] items-center justify-center gap-1.5 overflow-hidden rounded-md px-2.5 text-sm transition-colors hover:bg-gray-3 @min-[720px]/composer:justify-start ${
- unavailable ? "text-orange-600 dark:text-orange-400" : custom ? "text-gray-12" : "text-gray-10 hover:text-gray-12"
+ custom ? "text-gray-12" : "text-gray-10 hover:text-gray-12"
}`}
>
{saving ? <LoaderCircle className="size-4 shrink-0 animate-spin" /> : <Users className="size-4 shrink-0" />}
@@ -78,32 +78,8 @@ function SubagentModelPicker(props: { client: SubagentModelClient; policyLocked:
<DropdownMenuContent side="top" sideOffset={10} className="max-h-[min(560px,var(--available-height))] w-[min(340px,calc(100vw-32px))] overflow-y-auto p-2">
<DropdownMenuGroup>
<DropdownMenuLabel className="px-3 text-sm">Sub-agents: model</DropdownMenuLabel>
- <DropdownMenuRadioGroup value={setting.model ?? SAME}>
- <DropdownMenuRadioItem value={SAME} disabled={locked} data-testid="subagent-model-same" onClick={() => save({ model: null })}>
- {SAME_AS_MAIN_LABEL}
- </DropdownMenuRadioItem>
- {state.models.map((model) => (
- <DropdownMenuRadioItem
- key={model.id}
- value={model.id}
- disabled={locked}
- data-testid={`subagent-model-${model.id}`}
- onClick={() => save({ model: model.id })}
- >
- <span className="min-w-0">
- <span className="block truncate">{model.name}</span>
- {model.family && model.family !== "OpenAI" ? (
- <span className="block text-xs font-normal text-muted-foreground">{model.family}</span>
- ) : null}
- </span>
- </DropdownMenuRadioItem>
- ))}
- {setting.model && unavailable ? (
- <DropdownMenuRadioItem value={setting.model} disabled>
- {subagentModelName(state, setting.model)} (not available)
- </DropdownMenuRadioItem>
- ) : null}
- </DropdownMenuRadioGroup>
+ {/* Not a choice: a chat keeps one model, its sub-agents' too. */}
+ <p data-testid="subagent-model-pinned" aria-disabled="true" className="px-3 py-1.5 text-sm text-muted-foreground">{pinned}</p>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
@@ -126,7 +102,7 @@ function SubagentModelPicker(props: { client: SubagentModelClient; policyLocked:
</DropdownMenuRadioGroup>
</DropdownMenuGroup>
<DropdownMenuSeparator />
- <p className="px-3 py-2 text-xs text-muted-foreground">{SUBAGENT_MODEL_HELP}</p>
+ <p className="px-3 py-2 text-xs text-muted-foreground">{SUBAGENT_MODEL_PINNED_HELP}</p>
{props.policyLocked ? <p role="status" className="px-3 pb-2 text-xs text-muted-foreground">{SUBAGENT_MENU_POLICY_LOCK}</p> : null}
{error ? <p role="alert" className="px-3 pb-2 text-xs text-destructive">{error}</p> : null}
</DropdownMenuContent>
diff --git a/apps/app/src/react-app/domains/session/surface/session-surface.tsx b/apps/app/src/react-app/domains/session/surface/session-surface.tsx
index 935560d5..34d96f5b 100644
--- a/apps/app/src/react-app/domains/session/surface/session-surface.tsx
+++ b/apps/app/src/react-app/domains/session/surface/session-surface.tsx
@@ -3680,7 +3680,7 @@ export function SessionSurface(props: SessionSurfaceProps) {
runModeControl={<WorkspaceRunModeMenu client={props.client} workspaceId={props.workspaceId} busy={chatStreaming || preparingCloudTools || Boolean(props.activePermission || props.activeQuestion)} />}
fullPermissionsControl={<FullPermissionsToggle client={props.client} workspaceId={props.workspaceId} />}
sandboxControl={<SandboxStatusChip client={props.client} workspaceId={props.workspaceId} onOpenSettings={() => props.onOpenSettingsSection?.("sandbox")} />}
- subagentModelControl={<SubagentModelMenu client={props.client} />}
+ subagentModelControl={<SubagentModelMenu client={props.client} chatModel={props.selectedModel?.providerID === "omnirush" ? props.selectedModel.modelID : null} />}
voiceClient={props.client}
voiceWorkspaceId={props.workspaceId}
draft={autoSendPayload ? draft : autoSending ? "" : draft}
diff --git a/apps/app/src/react-app/domains/settings/subagent-model-settings.tsx b/apps/app/src/react-app/domains/settings/subagent-model-settings.tsx
index 7f69d09f..fd049e90 100644
--- a/apps/app/src/react-app/domains/settings/subagent-model-settings.tsx
+++ b/apps/app/src/react-app/domains/settings/subagent-model-settings.tsx
@@ -20,12 +20,10 @@ import {
import {
SAME_AS_MAIN_LABEL,
SUBAGENT_EFFORT_HELP,
- SUBAGENT_MODEL_HELP,
+ SUBAGENT_MODEL_PINNED_HELP,
subagentEffortLabel,
subagentEffortOptions,
- subagentModelName,
- subagentModelUnavailable,
- subagentSummary,
+ subagentPinnedSummary,
useSubagentModel,
type SubagentModelClient,
} from "./subagent-model";
@@ -33,7 +31,8 @@ import {
const SAME = "__same_as_main__";
/**
- * Settings > Preferences > Model: "Sub-agents: model" and "Sub-agent effort".
+ * Settings > Preferences > Model: "Sub-agents: model" (each chat's own: one
+ * model per chat, not a choice) and "Sub-agent effort".
* Shares its state with the composer's Sub-agents menu (useSubagentModel).
*/
export function SubagentModelSettings(props: { client: SubagentModelClient | null; busy?: boolean }) {
@@ -41,31 +40,22 @@ export function SubagentModelSettings(props: { client: SubagentModelClient | nul
const { state, setting, loading, saving, error, change } = useSubagentModel(props.client);
if (!props.client) return null;
const disabled = Boolean(props.busy) || policyLocked || saving || loading || !state;
- const unavailable = subagentModelUnavailable(state, setting);
- const models = state?.models ?? [];
- const modelItems = [
- { value: SAME, label: SAME_AS_MAIN_LABEL },
- ...models.map((model) => ({ value: model.id, label: model.family && model.family !== "OpenAI" ? `${model.name} (${model.family})` : model.name })),
- ...(setting.model && unavailable ? [{ value: setting.model, label: `${subagentModelName(state, setting.model)} (not available)` }] : []),
- ];
const effortItems = [
{ value: SAME, label: SAME_AS_MAIN_LABEL },
- ...subagentEffortOptions(state, setting.model).map((effort) => ({ value: effort, label: subagentEffortLabel(effort) })),
+ ...subagentEffortOptions(state, null).map((effort) => ({ value: effort, label: subagentEffortLabel(effort) })),
];
- const save = (next: { model?: string | null; effort?: string | null }) => {
+ const save = (next: { effort?: string | null }) => {
void change(next)
- .then((saved) => toast.success(`Sub-agents: ${subagentSummary(state, saved)}. Applies to new tasks.`))
+ .then((saved) => toast.success(`Sub-agents: ${subagentPinnedSummary(saved.effort)}. Applies to new tasks.`))
.catch((reason: unknown) => toast.error(reason instanceof Error ? reason.message : "The sub-agent setting could not be saved."));
};
const status = policyLocked
? "Locked by your organisation: its policy does not allow changing app settings."
: state && !state.signedIn
- ? "Sign in to omnirush.ai to pick a model for sub-agents."
- : unavailable
- ? "This model is not available to your account right now: sub-agents run on the main agent's model."
- : error;
+ ? "Sign in to omnirush.ai to set the sub-agent effort."
+ : error;
return (
<>
@@ -73,31 +63,12 @@ export function SubagentModelSettings(props: { client: SubagentModelClient | nul
<LayoutSectionItemHeader>
<LayoutSectionItemTitle>Sub-agents: model</LayoutSectionItemTitle>
<LayoutSectionItemDescription>
- {SUBAGENT_MODEL_HELP}
+ {SUBAGENT_MODEL_PINNED_HELP}
{status ? <span className="mt-1 block" data-testid="subagent-model-status">{status}</span> : null}
</LayoutSectionItemDescription>
<LayoutSectionItemHeaderActions>
- <div className="w-56 max-w-full">
- <Select
- value={setting.model ?? SAME}
- items={modelItems}
- onValueChange={(value) => {
- if (typeof value === "string") save({ model: value === SAME ? null : value });
- }}
- disabled={disabled || !state?.signedIn}
- >
- <SelectTrigger className="w-full" aria-label="Sub-agents: model" data-testid="settings-subagent-model">
- <SelectValue placeholder={SAME_AS_MAIN_LABEL} />
- </SelectTrigger>
- <SelectContent>
- <SelectGroup>
- {modelItems.map((item) => (
- <SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
- ))}
- </SelectGroup>
- </SelectContent>
- </Select>
- </div>
+ {/* Not a choice: a chat keeps one model, its sub-agents' too (model-modes.ts). */}
+ <span className="w-56 max-w-full text-sm text-muted-foreground" aria-disabled="true" data-testid="settings-subagent-model-pinned">Each chat's own model</span>
</LayoutSectionItemHeaderActions>
</LayoutSectionItemHeader>
</LayoutSectionItem>
diff --git a/apps/app/src/react-app/domains/settings/subagent-model.ts b/apps/app/src/react-app/domains/settings/subagent-model.ts
index 5c39f6f2..f340f6ad 100644
--- a/apps/app/src/react-app/domains/settings/subagent-model.ts
+++ b/apps/app/src/react-app/domains/settings/subagent-model.ts
@@ -76,6 +76,20 @@ export function subagentModelUnavailable(state: OmniRushSubagentModelState | und
return !state.signedIn || !state.models.some((entry) => entry.id === setting.model);
}
+/** One model per chat (model-modes.ts): sub-agents always run on their chat's model; only their effort is a setting. */
+export const SUBAGENT_MODEL_PINNED_HELP =
+ "One model per chat: sub-agents always run on their chat's model, at every nesting layer. Only their effort can be set.";
+
+/** "Sub-agents use this chat's model (GPT 6 Astra)". */
+export function subagentPinnedLabel(state: OmniRushSubagentModelState | undefined, chatModel: string | null): string {
+ return chatModel ? `Sub-agents use this chat's model (${subagentModelName(state, chatModel)})` : "Sub-agents use this chat's model";
+}
+
+/** What applies to sub-agents now that their model is the chat's: "Same as main agent" or "Chat's model · Low". */
+export function subagentPinnedSummary(effort: string | null): string {
+ return effort ? `Chat's model · ${formatGenericBehaviorLabel(effort)}` : SAME_AS_MAIN_LABEL;
+}
+
/** The server's setting and catalog, loaded once per server, and the action that saves a change. */
export function useSubagentModel(client: SubagentModelClient | null) {
const queryClient = useQueryClient();
diff --git a/apps/app/tests/subagent-model-menu.test.tsx b/apps/app/tests/subagent-model-menu.test.tsx
index 431afb87..c7ebb783 100644
--- a/apps/app/tests/subagent-model-menu.test.tsx
+++ b/apps/app/tests/subagent-model-menu.test.tsx
@@ -25,10 +25,11 @@ if (typeof globalThis.window === "undefined" || typeof globalThis.document === "
}
Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", { configurable: true, value: true });
-const [{ SubagentModelMenu }, { createOmniRushServerClient, OmniRushServerError }, { Popover, PopoverContent, PopoverTrigger }] = await Promise.all([
+const [{ SubagentModelMenu }, { createOmniRushServerClient, OmniRushServerError }, { Popover, PopoverContent, PopoverTrigger }, { SubagentModelSettings }] = await Promise.all([
import("../src/react-app/domains/session/surface/composer/subagent-model-menu"),
import("../src/app/lib/omnirush-server"),
import("../src/components/ui/popover"),
+ import("../src/react-app/domains/settings/subagent-model-settings"),
]);
const codex = ["low", "high", "xhigh", "max"];
@@ -85,33 +86,30 @@ function trigger(): HTMLElement | null {
return document.querySelector('[data-testid="subagent-model-trigger"]');
}
-test("shows 'Sub-agents' by default and saves a picked model from the menu", async () => {
+test("one model per chat: the menu names the chat's model as the sub-agents' (not a choice) and saves only the effort", async () => {
const { client, saved } = fakeClient({ model: null, effort: null });
- await mount(<SubagentModelMenu client={client} />);
+ await mount(<SubagentModelMenu client={client} chatModel="gpt-6-sol" />);
expect(trigger()?.textContent).toBe("Sub-agents");
expect(trigger()?.getAttribute("aria-label")).toBe("Sub-agents: Same as main agent");
await act(async () => { trigger()!.click(); });
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)); });
- const sol = document.querySelector<HTMLElement>('[data-testid="subagent-model-gpt-6-sol"]');
- expect(sol).not.toBeNull();
- expect(document.querySelector('[data-testid="subagent-model-meta-muse-spark"]')?.textContent).toContain("Meta Muse");
- await act(async () => { sol!.click(); });
+ expect(document.querySelector('[data-testid="subagent-model-pinned"]')?.textContent).toBe("Sub-agents use this chat's model (GPT 6 Sol)");
+ // No model to pick.
+ for (const id of ["gpt-6-astra", "gpt-6-sol", "meta-muse-spark"]) expect(document.querySelector(`[data-testid="subagent-model-${id}"]`)).toBeNull();
+ const high = document.querySelector<HTMLElement>('[data-testid="subagent-effort-high"]');
+ await act(async () => { high!.click(); });
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)); });
- expect(saved).toEqual([{ model: "gpt-6-sol", effort: null }]);
- expect(toasts).toEqual(["success:Sub-agents: GPT 6 Sol. Applies to new tasks."]);
- expect(trigger()?.textContent).toBe("GPT 6 Sol");
+ expect(saved).toEqual([{ model: null, effort: "high" }]);
+ expect(toasts).toEqual(["success:Sub-agents: Chat's model · High. Applies to new tasks."]);
+ expect(trigger()?.textContent).toBe("Chat's model · High");
});
-test("a picked model and effort show on the trigger; a model outside the catalog is flagged", async () => {
+test("a model saved before (older setting) never shows or applies: the chat's model does", async () => {
const { client } = fakeClient({ model: "meta-muse-spark", effort: "xhigh" });
- await mount(<SubagentModelMenu client={client} />);
- expect(trigger()?.textContent).toBe("Meta Muse Spark · Xhigh");
-
- const missing = fakeClient({ model: "muse-spark-1.3", effort: null });
- await mount(<SubagentModelMenu client={missing.client} />);
- const flagged = document.querySelectorAll('[data-testid="subagent-model-trigger"]')[1] as HTMLElement;
- expect(flagged.getAttribute("title")).toContain("not available, sub-agents use the main model");
+ await mount(<SubagentModelMenu client={client} chatModel="gpt-6-astra" />);
+ expect(trigger()?.textContent).toBe("Chat's model · Xhigh");
+ expect(trigger()?.getAttribute("title")).toBe("Sub-agents: Chat's model · Xhigh. Sub-agents use this chat's model (GPT 6 Astra).");
});
test("hidden without an omnirush.ai account", async () => {
@@ -123,26 +121,26 @@ test("hidden without an omnirush.ai account", async () => {
});
test("a save the server could not write shows its message and keeps the previous setting", async () => {
- const { client } = fakeClient({ model: "gpt-6-astra", effort: null });
+ const { client } = fakeClient({ model: null, effort: "low" });
const attempts: OmniRushSubagentModelSetting[] = [];
client.setSubagentModel = async (next: OmniRushSubagentModelSetting) => {
attempts.push(next);
throw new OmniRushServerError(500, "settings_write_failed", "The sub-agent setting could not be saved: EPERM", { code: "EPERM" });
};
await mount(<SubagentModelMenu client={client} />);
- expect(trigger()?.textContent).toBe("GPT 6 Astra");
+ expect(trigger()?.textContent).toBe("Chat's model · Low");
await act(async () => { trigger()!.click(); });
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)); });
- await act(async () => { document.querySelector<HTMLElement>('[data-testid="subagent-model-gpt-6-sol"]')!.click(); });
+ await act(async () => { document.querySelector<HTMLElement>('[data-testid="subagent-effort-high"]')!.click(); });
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)); });
- expect(attempts).toEqual([{ model: "gpt-6-sol", effort: null }]);
+ expect(attempts).toEqual([{ model: null, effort: "high" }]);
expect(toasts).toEqual(["error:The sub-agent setting could not be saved: EPERM"]);
- // Not shown as saved: the trigger and the checked item stay on the previous model.
- expect(trigger()?.textContent).toBe("GPT 6 Astra");
- expect(document.querySelector('[data-testid="subagent-model-gpt-6-astra"]')?.getAttribute("aria-checked")).toBe("true");
- expect(document.querySelector('[data-testid="subagent-model-gpt-6-sol"]')?.getAttribute("aria-checked")).toBe("false");
+ // Not shown as saved: the trigger and the checked item stay on the previous effort.
+ expect(trigger()?.textContent).toBe("Chat's model · Low");
+ expect(document.querySelector('[data-testid="subagent-effort-low"]')?.getAttribute("aria-checked")).toBe("true");
+ expect(document.querySelector('[data-testid="subagent-effort-high"]')?.getAttribute("aria-checked")).toBe("false");
expect(document.querySelector('[role="alert"]')?.textContent).toBe("The sub-agent setting could not be saved: EPERM");
});
@@ -197,15 +195,15 @@ test("in a narrow composer the chip is an icon that still names the setting, and
// The label only shows once the composer container is wide enough; the
// icon-only chip keeps the full summary for screen readers and the tooltip.
const label = document.querySelector('[data-testid="subagent-model-label"]')!;
- expect(label.textContent).toBe("Meta Muse Spark · Xhigh");
+ expect(label.textContent).toBe("Chat's model · Xhigh");
expect(label.className.split(" ")).toEqual(expect.arrayContaining(["hidden", "truncate", "@min-[720px]/composer:inline"]));
- expect(chip.getAttribute("aria-label")).toBe("Sub-agents: Meta Muse Spark · Xhigh");
- expect(chip.getAttribute("title")).toBe("Sub-agents: Meta Muse Spark · Xhigh");
+ expect(chip.getAttribute("aria-label")).toBe("Sub-agents: Chat's model · Xhigh");
+ expect(chip.getAttribute("title")).toBe("Sub-agents: Chat's model · Xhigh. Sub-agents use this chat's model.");
// It gives up its width before the model selector does, down to the icon.
expect(chip.className.split(" ")).toEqual(expect.arrayContaining(["min-w-9", "shrink-[4]", "overflow-hidden"]));
});
-test("the menu lists every model and stays inside the viewport, scrolling instead of running off the top", async () => {
+test("the menu stays inside the viewport, scrolling instead of running off the top", async () => {
const { client } = fakeClient({ model: "meta-muse-spark", effort: "xhigh" });
await mount(<SubagentModelMenu client={client} />);
await act(async () => { trigger()!.click(); });
@@ -216,9 +214,7 @@ test("the menu lists every model and stays inside the viewport, scrolling instea
expect(content.className).toContain("max-h-[min(560px,var(--available-height))]");
expect(content.className).toContain("overflow-y-auto");
expect(content.className).not.toContain("70vh");
- for (const id of ["gpt-6-astra", "gpt-6-sol", "gpt-5.6-sol", "meta-muse-spark", "muse-spark-1.1"]) {
- expect(document.querySelector(`[data-testid="subagent-model-${id}"]`)).not.toBeNull();
- }
+ expect(document.querySelector('[data-testid="subagent-model-pinned"]')).not.toBeNull();
});
test("Escape and an outside click close the menu; opening the model picker leaves only one menu open", async () => {
@@ -262,3 +258,12 @@ test("Escape and an outside click close the menu; opening the model picker leave
expect(document.querySelector('[data-testid="model-list"]')).not.toBeNull();
expect(document.querySelectorAll('[data-slot="dropdown-menu-content"], [data-slot="popover-content"]').length).toBe(1);
});
+
+test("Settings: the sub-agent model is each chat's own (no picker), with the one-model-per-chat note; the effort stays a setting", async () => {
+ const { client } = fakeClient({ model: "gpt-6-sol", effort: null });
+ const container = await mount(<SubagentModelSettings client={client} />);
+ expect(container.querySelector('[data-testid="settings-subagent-model"]')).toBeNull();
+ expect(container.querySelector('[data-testid="settings-subagent-model-pinned"]')?.textContent).toBe("Each chat's own model");
+ expect(container.textContent).toContain("One model per chat: sub-agents always run on their chat's model");
+ expect(container.querySelector('[data-testid="settings-subagent-effort"]')).not.toBeNull();
+});
diff --git a/apps/server/src/omnirush-subagent-model.routes.test.ts b/apps/server/src/omnirush-subagent-model.routes.test.ts
index d61c0df9..61f37df3 100644
--- a/apps/server/src/omnirush-subagent-model.routes.test.ts
+++ b/apps/server/src/omnirush-subagent-model.routes.test.ts
@@ -73,39 +73,20 @@ describe("sub-agent model routes", () => {
["gpt-6.1-sol", "GPT 6.1 Sol", "low,high,xhigh,max"],
["gpt-6-sol", "GPT 6 Sol", "low,high,xhigh,max"],
]);
- // A missing preference names GPT-5.6 Sol; a catalog that does not list it keeps the main model and effort.
- expect(await resolve({ sessionId: "ses_child", rootSessionId: "ses_main", inherited: main, main })).toMatchObject({
- model: { providerID: "omnirush", modelID: "gpt-6-astra" },
- variant: "max",
- fallback: { requested: "gpt-5.6-sol", used: "gpt-6-astra", reason: "not_in_catalog" },
- });
- // GPT 6.1 Sol, from the catalog, is a sub-agent model like any other.
+ // One model per chat: a saved sub-agent model never applies (sub-agents run on their chat's model); only the effort does.
+ expect(await resolve({ sessionId: "ses_child", rootSessionId: "ses_main", inherited: main, main })).toEqual({});
await fetch(`${base}/omnirush/subagent-model`, { method: "PUT", headers: client, body: JSON.stringify({ model: "gpt-6.1-sol", effort: "xhigh" }) });
- expect(await resolve({ sessionId: "ses_child", rootSessionId: "ses_main", inherited: main, main })).toEqual({
- model: { providerID: "omnirush", modelID: "gpt-6.1-sol" },
- variant: "xhigh",
- gatewayFallback: { model: "gpt-6-astra", effort: "xhigh" },
- });
+ const pinned = await resolve({ sessionId: "ses_child", rootSessionId: "ses_main", inherited: main, main });
+ expect(pinned).toMatchObject({ model: { providerID: "omnirush", modelID: "gpt-6-astra" }, variant: "xhigh" });
+ expect(pinned.fallback).toBeUndefined();
+ // A model the task asked for does not apply either.
+ expect(await resolve({ sessionId: "ses_child2", rootSessionId: "ses_main", inherited: main, main, requested: { providerID: "omnirush", modelID: "gpt-6-sol" } })).toMatchObject({ model: { providerID: "omnirush", modelID: "gpt-6-astra" } });
const bad = await fetch(`${base}/omnirush/subagent-model`, { method: "PUT", headers: client, body: JSON.stringify({ model: "gpt-6-sol", effort: "turbo" }) });
expect(bad.status).toBe(400);
- const put = await fetch(`${base}/omnirush/subagent-model`, { method: "PUT", headers: client, body: JSON.stringify({ model: "gpt-6-sol", effort: "high" }) });
- expect(await put.json()).toEqual({ ok: true, setting: { model: "gpt-6-sol", effort: "high" } });
- expect(await readSubagentModelSetting(config)).toEqual({ model: "gpt-6-sol", effort: "high" });
-
- expect(await resolve({ sessionId: "ses_child", rootSessionId: "ses_main", inherited: main, main })).toEqual({
- model: { providerID: "omnirush", modelID: "gpt-6-sol" },
- variant: "high",
- gatewayFallback: { model: "gpt-6-astra", effort: "high" },
- });
-
- // Meta Muse is not in this account's catalog: the sub-agent stays on the main model.
- await fetch(`${base}/omnirush/subagent-model`, { method: "PUT", headers: client, body: JSON.stringify({ model: "meta-muse-spark", effort: null }) });
- expect(await resolve({ sessionId: "ses_child", rootSessionId: "ses_main", inherited: main, main })).toMatchObject({
- model: { providerID: "omnirush", modelID: "gpt-6-astra" },
- variant: "max",
- fallback: { requested: "meta-muse-spark", used: "gpt-6-astra", reason: "not_in_catalog" },
- });
+ const put = await fetch(`${base}/omnirush/subagent-model`, { method: "PUT", headers: client, body: JSON.stringify({ model: "gpt-6-sol", effort: null }) });
+ expect(await put.json()).toEqual({ ok: true, setting: { model: "gpt-6-sol", effort: null } });
+ expect(await resolve({ sessionId: "ses_child", rootSessionId: "ses_main", inherited: main, main })).toEqual({});
// Back to "same as main".
await fetch(`${base}/omnirush/subagent-model`, { method: "PUT", headers: client, body: JSON.stringify({ model: null, effort: null }) });
diff --git a/apps/server/src/omnirush-subagent-model.ts b/apps/server/src/omnirush-subagent-model.ts
index e6008440..2f9839f9 100644
--- a/apps/server/src/omnirush-subagent-model.ts
+++ b/apps/server/src/omnirush-subagent-model.ts
@@ -317,6 +317,16 @@ export function subagentSettingFor(
return { model: requested.modelID, effort: parseSubagentEffort(requested.variant) ?? stored.effort };
}
+/**
+ * One model per chat (model-modes/): a chat's model is fixed once its first
+ * prompt is sent, and its sub-agents only start after that, so they always
+ * run on it. Of the setting (or a model a task asked for) only the effort
+ * applies; null when nothing is left to apply.
+ */
+export function pinnedSubagentSetting(setting: SubagentModelSetting | null): SubagentModelSetting | null {
+ return setting?.effort ? { model: null, effort: setting.effort } : null;
+}
+
/** A readable note for a sub-agent session that runs on the main model instead of the picked one. */
export function subagentFallbackNote(fallback: NonNullable<SubagentModelResolution["fallback"]> | { requestedName: string; usedName: string; reason: string }): string {
const why = fallback.reason === "not_in_catalog"
diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts
index 6f1694e9..8f9bf438 100644
--- a/apps/server/src/server.ts
+++ b/apps/server/src/server.ts
@@ -217,6 +217,7 @@ import {
sanitizeSubagentModelSetting,
subagentModelRefusals,
subagentSettingFor,
+ pinnedSubagentSetting,
writeSubagentModelSetting,
type EngineModelRef,
type SubagentModelSetting,
@@ -4602,8 +4603,9 @@ function createRoutes(
const body = await readJsonBody(ctx.request);
const inherited = engineModelRef(body.inherited);
if (!inherited) throw new ApiError(400, "invalid_payload", "inherited model is required");
- const setting = subagentSettingFor(await readSubagentModelSetting(config), engineModelRef(body.requested));
- if (!setting || (!setting.model && !setting.effort)) return jsonResponse({});
+ // Sub-agents run on their chat's model (one model per chat): only the effort applies.
+ const setting = pinnedSubagentSetting(subagentSettingFor(await readSubagentModelSetting(config), engineModelRef(body.requested)));
+ if (!setting) return jsonResponse({});
const refusals = subagentModelRefusals(config);
const resolution = resolveSubagentModel({
setting,