Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: sub-agents follow the main effort

ogsamrat87df228d6919
diff --git a/apps/server/src/omnirush-subagent-model.test.ts b/apps/server/src/omnirush-subagent-model.test.ts
index 5b1aa569..9d811b81 100644
--- a/apps/server/src/omnirush-subagent-model.test.ts
+++ b/apps/server/src/omnirush-subagent-model.test.ts
@@ -97,6 +97,37 @@ describe("resolve a sub-agent prompt", () => {
})).toEqual({});
});
+ test("same as main: a sub-agent on its own model follows the main session's effort", () => {
+ // The agent has its own model, so the engine put no variant on the prompt.
+ const muse = { providerID: "omnirush", modelID: "meta-muse-spark" };
+ expect(resolveSubagentModel({
+ setting: { model: null, effort: null },
+ catalog,
+ gateway: true,
+ inherited: { ...astra, variant: null },
+ main: { ...astra, variant: "low" },
+ })).toEqual({ model: astra, variant: "low" });
+ // Mapped to the nearest level the agent's model offers (Muse has no max).
+ expect(resolveSubagentModel({
+ setting: { model: null, effort: null },
+ catalog,
+ gateway: true,
+ inherited: muse,
+ main: { ...astra, variant: "max" },
+ })).toEqual({ model: muse, variant: "xhigh" });
+ // Main effort unknown (e.g. after a restart): left to the engine (model default).
+ expect(resolveSubagentModel({ setting: { model: null, effort: null }, catalog, gateway: true, inherited: muse, main: null })).toEqual({});
+ expect(resolveSubagentModel({ setting: { model: null, effort: null }, catalog, gateway: true, inherited: muse })).toEqual({});
+ // Another provider's model: untouched.
+ expect(resolveSubagentModel({
+ setting: { model: null, effort: null },
+ catalog,
+ gateway: true,
+ inherited: { providerID: "openai", modelID: "gpt-5.5" },
+ main: { ...astra, variant: "low" },
+ })).toEqual({});
+ });
+
test("a picked catalog model runs the sub-agent; the main effort maps to the model's nearest level", () => {
expect(resolveSubagentModel({
setting: { model: "meta-muse-spark", effort: null },
diff --git a/apps/server/src/omnirush-subagent-model.ts b/apps/server/src/omnirush-subagent-model.ts
index ca696555..e6008440 100644
--- a/apps/server/src/omnirush-subagent-model.ts
+++ b/apps/server/src/omnirush-subagent-model.ts
@@ -5,7 +5,8 @@
*
* The setting is kept at <runtimeStorageDir>/omnirush-subagent-model.json.
* An explicit "same as main" setting (both fields null) keeps the engine's
- * inheritance. A missing setting uses GPT-5.6 Sol with the main agent's
+ * inheritance, and gives a sub-agent on its own model (no inherited variant)
+ * the main session's effort. A missing setting uses GPT-5.6 Sol with the main agent's
* inherited effort; users can still select another model in Preferences.
*
* Who does what:
@@ -237,7 +238,18 @@ export function resolveSubagentModel(input: {
refused?: (model: string) => boolean;
}): SubagentModelResolution {
const { setting, catalog, inherited } = input;
- if (!setting.model && !setting.effort) return {};
+ if (!setting.model && !setting.effort) {
+ // "Same as main": the engine already carries the delegating agent's
+ // effort, unless the sub-agent agent has its own model (the engine then
+ // sends no variant and the model default would apply). Then the main
+ // session's effort, mapped to the nearest level the model offers.
+ const mainEffort = input.main?.variant;
+ if (inherited.variant || !mainEffort || levelsOf(catalog, inherited) === null) return {};
+ return {
+ model: { providerID: inherited.providerID, modelID: inherited.modelID },
+ variant: effortFor(catalog, inherited, null, mainEffort),
+ };
+ }
const defaultModel = catalog.find((model) => model.default) ?? catalog[0];
const main: EngineModelRef & { variant?: string | null } = input.main
?? (setting.model && inherited.providerID === OMNIRUSH_PROVIDER_ID && inherited.modelID === setting.model && defaultModel