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

Closed
opened 2026-02-16 18:04:27 -05:00 by yindo · 1 comment
Owner

Originally created by @sethcarlton on GitHub (Jan 16, 2026).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @sethcarlton on GitHub (Jan 16, 2026). Originally assigned to: @rekram1-node on GitHub. ### 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:** ```md --- 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). ```bash --- description: Test md file creation agent: foo --- Create a test.md file with the text "bar". If the file exists, update it with "bar". ``` 4. **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** <img width="1187" height="732" alt="Image" src="https://github.com/user-attachments/assets/1004699c-7886-4ca5-b71c-e1a9b7b42760" /> **After navigating back to primary agent** <img width="1188" height="732" alt="Image" src="https://github.com/user-attachments/assets/8e61a233-5c5a-496d-b876-c9ff7a48106a" /> ### Operating System macOS 15.7.3 ### Terminal Ghostty
yindo added the bug label 2026-02-16 18:04:27 -05:00
yindo closed this issue 2026-02-16 18:04:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7430: Models in subagents override TUI session model

Feel free to ignore if this doesn't address your specific case.

@github-actions[bot] commented on GitHub (Jan 16, 2026): This issue might be a duplicate of existing issues. Please check: - #7430: Models in subagents override TUI session model Feel free to ignore if this doesn't address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6518