Agents: fix subagent model precedence#58003
Merged
obviyus merged 1 commit intoMar 31, 2026
Merged
Conversation
Contributor
Greptile SummaryThis PR fixes a subagent model precedence bug where
Confidence Score: 5/5
Reviews (1): Last reviewed commit: "Agents: fix subagent model precedence" | Re-trigger Greptile |
This comment was marked as spam.
This comment was marked as spam.
afd1490 to
40feb69
Compare
obviyus
approved these changes
Mar 31, 2026
obviyus
left a comment
Contributor
There was a problem hiding this comment.
Reviewed latest changes; landing now.
Contributor
|
Landed on main. Thanks @neeravmakwana. |
This was referenced Mar 31, 2026
Closed
This was referenced Mar 31, 2026
joeykrug
added a commit
to joeykrug/openclaw
that referenced
this pull request
Apr 26, 2026
…t own model PR openclaw#58003 reordered resolveSubagentConfiguredModelSelection to prefer agentConfig.model over agents.defaults.subagents.model. This caused the main agent's own model to shadow the global subagent default — e.g. when the main agent runs Opus and defaults.subagents.model is GPT-5.4, subagents incorrectly inherited Opus instead of GPT-5.4. Restore the correct precedence: 1. agentConfig.subagents.model (explicit per-agent subagent config) 2. agents.defaults.subagents.model (global subagent default) 3. agentConfig.model (agent own model, last-resort fallback) Apply the same fix to the cron isolated-agent model selection path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 30, 2026
This was referenced May 15, 2026
martingarramon
added a commit
to martingarramon/openclaw
that referenced
this pull request
May 20, 2026
…gentModelConfigSelectionResult PR openclaw#58003 (e394262) introduced a regression in agent-scope.ts: agentConfig.model (the agent's own model) was placed before cfg.agents.defaults.subagents.model (the global subagent default) in the candidates array. This shadowed the global default for any agent that has its own model configured — the common case. openclaw#81783 fixed the same regression in model-selection.ts but the agent-scope.ts path was missed. This path is used by the cron isolation runner and resolveSubagentModel- FallbacksOverride. Correct precedence: 1. agentConfig.subagents.model (per-agent subagent config) 2. cfg.agents.defaults.subagents.model (global subagent default) 3. agentConfig.model (agent's own model — last resort only) Closes openclaw#58822.
martingarramon
added a commit
to martingarramon/openclaw
that referenced
this pull request
May 23, 2026
…gentModelConfigSelectionResult PR openclaw#58003 (e394262) introduced a regression in agent-scope.ts: agentConfig.model (the agent's own model) was placed before cfg.agents.defaults.subagents.model (the global subagent default) in the candidates array. This shadowed the global default for any agent that has its own model configured — the common case. openclaw#81783 fixed the same regression in model-selection.ts but the agent-scope.ts path was missed. This path is used by the cron isolation runner and resolveSubagentModel- FallbacksOverride. Correct precedence: 1. agentConfig.subagents.model (per-agent subagent config) 2. cfg.agents.defaults.subagents.model (global subagent default) 3. agentConfig.model (agent's own model — last resort only) Closes openclaw#58822.
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.
Summary
sessions_spawnand related subagent model resolution preferredagents.defaults.subagents.modelover a named agent's ownmodel.primary, so per-agent model defaults were ignored.modeloverride.agents.list[].subagents.model, thenagents.list[].model.primary, thenagents.defaults.subagents.model, and mirrored that precedence in isolated cron model resolution.modeloverrides still win, and no broader agent/default model resolution behavior was changed.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
resolveSubagentConfiguredModelSelectioninsrc/agents/model-selection.tsplacedagents.defaults.subagents.modelahead of the target agent's ownmodel, so the global subagent default masked the per-agent primary model.model.primarybeats the global subagent default whensubagents.modelis unset.git blame, prior PR, issue, or refactor if known): issue [Bug]: agents.list[].model.primary ignored - agents.defaults.subagents.model always wins #57993 reported the precedence mismatch with a direct repro.Regression Test Plan (if applicable)
src/agents/model-selection.test.ts,src/cron/isolated-agent.subagent-model.test.ts, andsrc/gateway/sessions-patch.test.tsmodel.primaryis used for subagents unless a more specificagents.list[].subagents.modelor explicit runtime override is present.src/gateway/sessions-patch.test.tsalready covered adjacent allowlist behavior and was updated to stay aligned with the corrected precedence.User-visible / Behavior Changes
model.primaryfor spawned subagents whenagents.list[].subagents.modelis unset, even ifagents.defaults.subagents.modelis configured.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Environment
agents.defaults.subagents.model,agents.list[].model.primary, optionalagents.list[].subagents.modelSteps
agents.defaults.subagents.modeland a named agent with a differentmodel.primary.modeloverride.Expected
model.primaryis used unlessagents.list[].subagents.modelis configured.Actual
agents.defaults.subagents.modelwon and masked the named agent'smodel.primary.Evidence
Human Verification (required)
pnpm checkandpnpm build.subagents.modelstill outranks agentmodel.primary; explicit runtime/job model overrides still outrank config defaults; globaldefaults.subagents.modelstill applies when the agent has no explicit model.pnpm teststill reports the existing unrelated failure insrc/cli/config-cli.test.tsabout--containerexamples in help text.AI Assistance
Review Conversations
Compatibility / Migration
Risks and Mitigations
Made with Cursor