openclaw - 💡(How to fix) Fix Sub-agent model routing silently ignored - explicit model= falls back to primary model [1 comments, 2 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#73444Fetched 2026-04-29 06:19:51
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
closed ×1commented ×1

buildDirectChildSessionPatch() writes the model to session display metadata fields (model, modelProvider) but the execution engine reads override fields (modelOverride, providerOverride). Explicit sessions_spawn(model="...") calls and agents.defaults.subagents.model config are silently ignored, causing all sub-agents to fall back to the parent agent's primary model.

Error Message

  1. Explicit model= silently ignored (no warning, no error)

Root Cause

Root Cause

Fix Action

Fix

Add override fields in buildDirectChildSessionPatch():

if (typeof patch.model === "string" && patch.model.trim()) {
    const { provider, model } = splitModelRef(patch.model.trim());
    if (model) {
        entry.model = model;
        entry.modelOverride = model;
        if (provider) {
            entry.modelProvider = provider;
            entry.providerOverride = provider;
        }
    }
}

Code Example

function buildDirectChildSessionPatch(patch) {
    const entry = {};
    if (typeof patch.model === "string" && patch.model.trim()) {
        const { provider, model } = splitModelRef(patch.model.trim());
        if (model) {
            entry.model = model;
            if (provider) entry.modelProvider = provider;
        }
    }
    return entry;
}

---

return runEmbeddedPiAgent({
    provider: params.providerOverride,
    model: params.modelOverride,
    ...
});

---

if (typeof patch.model === "string" && patch.model.trim()) {
    const { provider, model } = splitModelRef(patch.model.trim());
    if (model) {
        entry.model = model;
        entry.modelOverride = model;
        if (provider) {
            entry.modelProvider = provider;
            entry.providerOverride = provider;
        }
    }
}
RAW_BUFFERClick to expand / collapse

Sub-Agent Model Routing Ignored

Summary

buildDirectChildSessionPatch() writes the model to session display metadata fields (model, modelProvider) but the execution engine reads override fields (modelOverride, providerOverride). Explicit sessions_spawn(model="...") calls and agents.defaults.subagents.model config are silently ignored, causing all sub-agents to fall back to the parent agent's primary model.

Environment

  • OpenClaw: 2026.4.25
  • File: dist/subagent-spawn-cbH-XgdN.js
  • Function: buildDirectChildSessionPatch(patch)

Root Cause

What buildDirectChildSessionPatch() does:

function buildDirectChildSessionPatch(patch) {
    const entry = {};
    if (typeof patch.model === "string" && patch.model.trim()) {
        const { provider, model } = splitModelRef(patch.model.trim());
        if (model) {
            entry.model = model;
            if (provider) entry.modelProvider = provider;
        }
    }
    return entry;
}

What the execution engine reads:

return runEmbeddedPiAgent({
    provider: params.providerOverride,
    model: params.modelOverride,
    ...
});

The disconnect:

  • model / modelProvider are display metadata (used by /subagents list)
  • modelOverride / providerOverride are what the actual execution engine uses
  • The spawn handler only populates display fields, never override fields
  • Result: modelOverride is undefined → runtime falls back to parent primary model

Reproduction Steps

  1. Parent agent configured with primary model = anthropic/claude-opus-4-7
  2. Spawn sub-agent: sessions_spawn(model="local-qwen36/Qwen3.6-35B-A3B...", task="...")
  3. Sub-agent runs on Opus 4.7 instead of specified local model
  4. Explicit model= silently ignored (no warning, no error)

Expected Behavior

Sub-agent uses the explicitly specified model.

Actual Behavior

Sub-agent silently falls back to parent agent's primary model.

Fix

Add override fields in buildDirectChildSessionPatch():

if (typeof patch.model === "string" && patch.model.trim()) {
    const { provider, model } = splitModelRef(patch.model.trim());
    if (model) {
        entry.model = model;
        entry.modelOverride = model;
        if (provider) {
            entry.modelProvider = provider;
            entry.providerOverride = provider;
        }
    }
}

Impact

  • All sub-agent model specifications are silently ignored
  • sessions_spawn(model="...") never works as documented
  • agents.defaults.subagents.model config never takes effect
  • Sub-agents always use parent's primary model
  • Cost impact: every sub-agent runs on expensive primary model

Files Affected

  • dist/subagent-spawn-cbH-XgdN.jsbuildDirectChildSessionPatch()

Verification

  • Local patch applied and verified: sub-agents correctly route to specified model
  • Trajectory logs confirm spawn params include correct model but execution uses parent model

extent analysis

TL;DR

The most likely fix is to update the buildDirectChildSessionPatch() function to populate both display metadata fields (model, modelProvider) and override fields (modelOverride, providerOverride) to ensure sub-agents use the specified model.

Guidance

  • Verify that the buildDirectChildSessionPatch() function is correctly populating the model and modelProvider fields, and update it to also populate modelOverride and providerOverride fields.
  • Check the sessions_spawn() function to ensure it is passing the correct model parameter to buildDirectChildSessionPatch().
  • Test the updated buildDirectChildSessionPatch() function with different model specifications to ensure sub-agents are using the correct models.
  • Review the trajectory logs to confirm that the spawn params include the correct model and that the execution engine is using the specified model.

Example

function buildDirectChildSessionPatch(patch) {
    const entry = {};
    if (typeof patch.model === "string" && patch.model.trim()) {
        const { provider, model } = splitModelRef(patch.model.trim());
        if (model) {
            entry.model = model;
            entry.modelOverride = model;
            if (provider) {
                entry.modelProvider = provider;
                entry.providerOverride = provider;
            }
        }
    }
    return entry;
}

Notes

The provided fix assumes that the splitModelRef() function is correctly splitting the model reference into provider and model. If this function is not working correctly, additional debugging may be necessary.

Recommendation

Apply the workaround by updating the buildDirectChildSessionPatch() function to populate both display metadata fields and override fields, as this will ensure that sub-agents use the specified model and fix the silent fallback to the parent agent's primary model.

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 - 💡(How to fix) Fix Sub-agent model routing silently ignored - explicit model= falls back to primary model [1 comments, 2 participants]