Skip to content

Primary agent model switches to subagent model after returning to session #8946

@sethcarlton

Description

@sethcarlton

Description

After running a subagent with a different model than the primary agent, returning to the main session may cause the primary agent to adopt the subagent’s model.

Plugins

No response

OpenCode version

1.1.23

Steps to reproduce

Setup

  • Primary agent model: openai/gpt-5.2-codex
  • Subagent config example:
---
description: Foo agent
mode: subagent
model: opencode/gemini-3-flash
---

You are a foo agent

Steps to Reproduce

  1. Open a new session.
  2. Send a message as the primary agent (e.g., “Hi how are you”).
  3. Invoke the subagent so it produces output and becomes the last message. For example, using the following /foo command. To reproduce it consistently, you can interrupt the subagent during its work (see screenshot).
---
description: Test md file creation
agent: foo
---

Create a test.md file with the text "bar". If the file exists, update it with "bar".
  1. Navigate to the subagent output view, then navigate back to the primary agent.

Behavior

Expected Behavior

The primary agent should remain on its configured model: openai/gpt-5.2-codex

Actual Behavior

The primary agent incorrectly switches to the subagent model: opencode/gemini-3-flash

Notes / Additional Repro Paths

This issue only presents itself with the subagent appears as the last agent used in the list. I seem to getting mixed results on whether or not the flow is passed back to the primary agent or not. The issue can also occur during the following scenarios:

  • Session Switching: Switching sessions via /session and then returning to the original session.
  • App Restart: Closing OpenCode, reopening the application, and revisiting the session

Screenshot and/or share link

Before navigating to sub agent output
Image

After navigating back to primary agent
Image

Operating System

macOS 15.7.3

Terminal

Ghostty

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions