Fix subagent default model precedence#81783
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. from source inspection: current main resolves a target agent primary model before Real behavior proof Next step before merge Security Review detailsBest possible solution: Land this resolver and test change after maintainer review and acceptable real behavior proof, while keeping legacy whole-agent runtime inheritance out of scope unless maintainers explicitly change the runtime contract. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection: current main resolves a target agent primary model before Is this the best way to solve the issue? Yes for the supported model-scoped runtime path: reordering the existing resolver is the narrowest fix and the added tests cover the precedence and runtime-policy attachment. It does not implement legacy What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c8228245039b. |
* fix subagent default model precedence * docs changelog for subagent default fix
* fix subagent default model precedence * docs changelog for subagent default fix
…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.
…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.
* fix subagent default model precedence * docs changelog for subagent default fix
* fix subagent default model precedence * docs changelog for subagent default fix
* fix subagent default model precedence * docs changelog for subagent default fix
Summary
Fixes #81395.
agents.defaults.subagents.modelnow wins over a target agent's regular primary model when planningsessions_spawn, so documented subagent defaults are applied before runtime selection. This keeps model-scoped runtime policy, includingagentRuntime: { id: "claude-cli" }, attached to the model selected for the child run instead of silently falling back to the target agent's primary model.Real behavior proof
Behavior addressed: subagent model-default precedence and the runtime-policy bypass from #81395.
Real environment tested: Blacksmith Testbox via Crabbox on Linux, using the patched branch checkout.
Exact steps or command run after this patch:
node --import tsx -e 'import { resolveSubagentModelAndThinkingPlan } from "./src/agents/subagent-spawn-plan.ts"; import { resolveAgentHarnessPolicy } from "./src/agents/harness/policy.ts"; /* resolve a config with agents.defaults.subagents.model, model-scoped claude-cli runtime, and a conflicting target agent primary model */'Evidence after fix: Terminal output from Crabbox lease
tbx_01krjzk0205rnj59p7th1qfpp5, GitHub Actions run https://github.com/openclaw/openclaw/actions/runs/25854477958:{ "selectedSubagentModel": "anthropic/claude-sonnet-4-6", "childInitialSessionModel": "anthropic/claude-sonnet-4-6", "modelOverrideSource": "auto", "targetAgentPrimaryModel": "anthropic/claude-opus-4-7", "runtime": { "runtime": "claude-cli", "runtimeSource": "model" } }Observed result after fix: the default subagent model was selected despite the target agent primary model, and the selected model's
claude-cliruntime policy was preserved.What was not tested: live Claude CLI OAuth billing behavior; no provider credentials were needed for this deterministic config/routing fix.
Verification
Behavior addressed: subagent model-default precedence and the runtime-policy bypass from #81395.
Real environment tested: Blacksmith Testbox via Crabbox on Linux.
Exact steps or command run after this patch:
env CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 node scripts/run-vitest.mjs src/agents/model-selection.test.ts src/agents/openclaw-tools.subagents.sessions-spawn.model.test.ts src/agents/harness/selection.test.ts src/agents/tools/agents-list-tool.test.tsEvidence after fix: Crabbox lease
tbx_01krjxvxwmtycxvs3djsnfnk77, GitHub Actions run https://github.com/openclaw/openclaw/actions/runs/25853218918.Observed result after fix: 7 test files passed, 254 tests passed.
What was not tested: live Claude CLI OAuth billing behavior; the fix is deterministic config/routing precedence and was validated without provider credentials.