diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 4558914cb7e..795f7ec695d 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -145,8 +145,12 @@ export function Prompt(props: PromptProps) { if (msg.agent && isPrimaryAgent) { local.agent.set(msg.agent) } - if (msg.model) local.model.set(msg.model) - if (msg.variant) local.model.variant.set(msg.variant) + + const isolateModel = sync.data.config.isolate_subagent_model + if (!isolateModel) { + if (msg.model) local.model.set(msg.model) + if (msg.variant) local.model.variant.set(msg.variant) + } } }) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index ead3a0149b4..f6422b5b1be 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -871,6 +871,10 @@ export namespace Config { .boolean() .optional() .describe("@deprecated Use 'share' field instead. Share newly created sessions automatically"), + isolate_subagent_model: z + .boolean() + .optional() + .describe("Prevent commands and subagents from persisting their model to the parent session"), autoupdate: z .union([z.boolean(), z.literal("notify")]) .optional() diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts index 9cb7222aa5f..4e57a97925b 100644 --- a/packages/sdk/js/src/v2/gen/types.gen.ts +++ b/packages/sdk/js/src/v2/gen/types.gen.ts @@ -1590,6 +1590,10 @@ export type Config = { * @deprecated Use 'share' field instead. Share newly created sessions automatically */ autoshare?: boolean + /** + * Prevent commands and subagents from persisting their model to the parent session + */ + isolate_subagent_model?: boolean /** * Automatically update to the latest version. Set to true to auto-update, false to disable, or 'notify' to show update notifications */