openclaw - ✅(Solved) Fix Bug: Sub-agent model override not working in 2026.3.13 [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#51545Fetched 2026-04-08 01:09:47
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×2cross-referenced ×1

Sub-agents ignore agents.list[].model configuration and always fall back to the requester's active model or agents.defaults.subagents.model. This appears to be a regression or incomplete fix for issues #6671, #8460.

Root Cause

Sub-agents ignore agents.list[].model configuration and always fall back to the requester's active model or agents.defaults.subagents.model. This appears to be a regression or incomplete fix for issues #6671, #8460.

Fix Action

Workaround

Use direct API calls for specific models instead of sub-agents.

PR fix notes

PR #53262: fix: Make agentId required in sessions_spawn tool schema

Description (problem / solution / changelog)

Summary

Make agentId a required parameter in the sessions_spawn tool schema instead of optional.

Problem

When agentId is optional, models frequently omit it when spawning subagents — especially on retry/revision calls deeper in the conversation. The silent fallback to the requester's own agent ID causes subagents to run under the parent's identity instead of the intended target agent.

In testing with Claude Haiku 4.5, agentId was omitted on ~80% of re-spawn calls (revisions after fact-check failures), while included on ~80% of initial spawns copied from the prompt template. Making the field required at the schema level achieved 100% inclusion — schema enforcement is more reliable than prompt engineering.

Solution

Remove Type.Optional() from agentId in SessionsSpawnToolSchema. The model now sees agentId as required in the tool definition and must always specify it. Agents can still spawn copies of themselves by passing their own ID explicitly.

The implementation layer (readStringParam + fallback in subagent-spawn.ts) is unchanged and remains backward-compatible.

Related Issues

Closes #29368 — Option to require agentId for sub-agent spawning Closes #29982 — Block generic subagent spawns

Testing

  • Added test verifying agentId is in the schema's required array
  • Updated all existing spawn tests to include agentId
  • All 82 spawn-related tests pass
  • Full test suite passes (7958 tests)

Changed files

  • src/agents/openclaw-tools.subagents.sessions-spawn-applies-thinking-default.test.ts (modified, +1/-1)
  • src/agents/openclaw-tools.subagents.sessions-spawn-default-timeout-absent.test.ts (modified, +1/-1)
  • src/agents/openclaw-tools.subagents.sessions-spawn-default-timeout.test.ts (modified, +1/-1)
  • src/agents/openclaw-tools.subagents.sessions-spawn-depth-limits.test.ts (modified, +26/-8)
  • src/agents/openclaw-tools.subagents.sessions-spawn.allowlist.test.ts (modified, +12/-6)
  • src/agents/openclaw-tools.subagents.sessions-spawn.lifecycle.test.ts (modified, +2/-0)
  • src/agents/openclaw-tools.subagents.sessions-spawn.model.test.ts (modified, +1/-0)
  • src/agents/openclaw-tools.subagents.sessions-spawn.test-harness.ts (modified, +11/-0)
  • src/agents/sessions-spawn-threadid.test.ts (modified, +1/-0)
  • src/agents/subagent-spawn.attachments.test.ts (modified, +23/-0)
  • src/agents/tools/sessions-spawn-tool.test.ts (modified, +12/-0)
  • src/agents/tools/sessions-spawn-tool.ts (modified, +4/-2)

Code Example

{
  "agents": {
    "list": [{
      "id": "laptop-coder",
      "model": "ollama-laptop/qwen3-coder:30b",
      "subagents": {
        "model": "ollama-laptop/qwen3-coder:30b"
      }
    }]
  }
}
RAW_BUFFERClick to expand / collapse

Summary

Sub-agents ignore agents.list[].model configuration and always fall back to the requester's active model or agents.defaults.subagents.model. This appears to be a regression or incomplete fix for issues #6671, #8460.

Environment

  • OpenClaw Version: 2026.3.13 (61d171a)
  • OS: macOS 26.3.2 (arm64)
  • Node.js: v22.22.1

Expected Behavior

Sub-agents should use the model configured in agents.list[].model when spawning via sessions_spawn({agentId: "..."}).

Actual Behavior

Sub-agents always inherit the requester's model (kimi-k2.5:cloud) regardless of:

  1. agents.list[].model as string
  2. agents.list[].model.primary object
  3. agents.list[].subagents.model override
  4. Explicit model parameter in sessions_spawn

Configuration Tested

{
  "agents": {
    "list": [{
      "id": "laptop-coder",
      "model": "ollama-laptop/qwen3-coder:30b",
      "subagents": {
        "model": "ollama-laptop/qwen3-coder:30b"
      }
    }]
  }
}

Steps to Reproduce

  1. Configure agent with specific model
  2. Spawn sub-agent via sessions_spawn
  3. Observe: Sub-agent uses requester's model instead of configured model

References

  • Related issues: #6671, #8460, #40159, #47358
  • PRs that should have fixed this: #8474, #8510 (merged Feb 13 2026)

Workaround

Use direct API calls for specific models instead of sub-agents.

Request

Please investigate why PR #8474/#8510 fix is not working in 2026.3.13 release.

extent analysis

Fix Plan

To resolve the issue of sub-agents ignoring the agents.list[].model configuration, we need to update the sessions_spawn function to respect the model specified in the agent's configuration.

Code Changes

We will modify the sessions_spawn function to check for the model property in the agent's configuration and use it when spawning a sub-agent. Here is an example of the updated code:

// Update sessions_spawn function to respect agent's model configuration
function sessions_spawn({ agentId, model: overrideModel }) {
  const agent = agents.list.find((a) => a.id === agentId);
  if (agent) {
    // Use the model from the agent's configuration if available
    const model = overrideModel || agent.model || agent.subagents.model;
    // Spawn the sub-agent with the specified model
    return spawnSubAgent(agentId, model);
  }
  // Fallback to default behavior
  return spawnSubAgent(agentId, overrideModel);
}

Configuration Changes

No changes are required to the configuration. The existing configuration should work with the updated sessions_spawn function.

Verification

To verify that the fix worked, follow these steps:

  • Configure an agent with a specific model in agents.list[].model.
  • Spawn a sub-agent using sessions_spawn with the agent's ID.
  • Check that the sub-agent uses the configured model instead of the requester's model.

Extra Tips

  • Make sure to update the sessions_spawn function in the correct file and module.
  • If using a version control system, commit the changes and verify that the fix works in a new build or deployment.
  • Consider adding tests to ensure that the sessions_spawn function behaves correctly with different configurations and input parameters.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Bug: Sub-agent model override not working in 2026.3.13 [1 pull requests, 2 comments, 3 participants]