fix: make spawned subagents follow the parent session's model - #115
Open
SergioGen wants to merge 1 commit into
Open
fix: make spawned subagents follow the parent session's model#115SergioGen wants to merge 1 commit into
SergioGen wants to merge 1 commit into
Conversation
The spawn_agent tool created subagent sessions via session.prompt without passing a model, so they fell back to the model baked into the agent config at plugin startup. Switching models with /models only affects the running session, so subagents kept using the stale model and errored out after a rate limit. Capture the active model from each chat.message and replay it onto child sessions (including nested spawns like executor -> implementer).
SergioGen
force-pushed
the
fix/subagent-model-follow
branch
from
August 23, 2026 05:36
9da58cd to
fb01e92
Compare
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/tools/spawn-agent.ts">
<violation number="1" location="src/tools/spawn-agent.ts:68">
P2: When an agent has a `micode.json` model override, this request-level `model` replaces that explicit per-agent choice for every spawned run. Resolve the task agent's configured override first, and inherit the parent model only when no per-agent model is configured.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| body: { | ||
| parts: [{ type: "text", text: task.prompt }], | ||
| agent: task.agent, | ||
| ...(model ? { model } : {}), |
There was a problem hiding this comment.
P2: When an agent has a micode.json model override, this request-level model replaces that explicit per-agent choice for every spawned run. Resolve the task agent's configured override first, and inherit the parent model only when no per-agent model is configured.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tools/spawn-agent.ts, line 68:
<comment>When an agent has a `micode.json` model override, this request-level `model` replaces that explicit per-agent choice for every spawned run. Resolve the task agent's configured override first, and inherit the parent model only when no per-agent model is configured.</comment>
<file context>
@@ -58,15 +59,20 @@ async function executeAgentSession(ctx: PluginInput, task: AgentTask): Promise<s
body: {
parts: [{ type: "text", text: task.prompt }],
agent: task.agent,
+ ...(model ? { model } : {}),
},
query: { directory: ctx.directory },
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Subagents spawned via the spawn_agent tool create sessions through session.prompt without passing a model, so they fall back to the model baked into the agent config at plugin startup. Switching models with /models only affects the running session, so subagents keep using the stale model - after a rate limit they error out even though the user switched models.
Fix
Changes
Verification
Summary by cubic
Spawned subagents now inherit the parent session’s active model. Previously,
spawn_agentsessions ignored/modelsand fell back to the startup-baked model, which could trigger rate-limit errors.chat.message, store it in-memory per session, and include it inspawn_agentsession.prompt; also set it on the child so nested spawns follow.session.deleted.src/session-model.tsand unit tests for get/set/delete of the session model map.Written for commit fb01e92. Summary will update on new commits.