fix: keep primary model after subagent runs #8951
Merged
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Prevents subagent model from overriding primary agent model in TUI.
Fixes #8946
Fixes #7430
Reasoning
The existing
isPrimaryAgentguard already prevents subagent names from overriding the primary agent selection. Model and variant appear to have been unintentionally left outside this guard, causing the leak. This fix moves them inside the same guard for consistency.There is an existing PR #7428 that proposes a config option to opt-in to isolation. This would work but I think this is a bug and not a feature?
Verification
Tested according to repro steps in #8946: configured subagent with different model, invoked it, interrupted during work, navigated back to primary agent, the primary agent model was retained.
Note: the web app (
packages/app/src/pages/session.tsx) may have the same bug but is not addressed here.