openclaw - ✅(Solved) Fix sessions_spawn model override ignored — all subagents fall back to default primary model [1 pull requests, 1 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#74626Fetched 2026-04-30 06:22:03
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
referenced ×3cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #74730: fix(sessions_spawn): pass model override to gateway agent method(#74626)

Description (problem / solution / changelog)

Summary

  • Problem: sessions_spawn tool ignores the model parameter override. When users spawn subagents with explicit models (e.g. deepseek/deepseek-v4-pro, ollama/kimi-k2.6:cloud), all subagents fall back to the configured primary model instead of using the requested model.
  • Why it matters: Users cannot control which model runs their subagents, defeating the purpose of per-spawn model selection and causing unexpected behavior/costs when specific models are required for tasks.
  • What changed: Added provider/model parameters to the callSubagentGateway agent call in subagent-spawn.ts. The resolvedModel string is now parsed via splitModelRef and passed through to the gateway, enabling the model override to reach the agent runtime.
  • What did NOT change (scope boundary): No changes to model selection logic, validation, or authorization. Only the parameter forwarding path was fixed. Gateway agent method schema already supported these parameters.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #74626
  • Related #
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: In subagent-spawn.ts spawnSubagentDirect(), the resolvedModel was correctly computed from user overrides and config precedence, but the subsequent callSubagentGateway({ method: "agent" }) call did not include provider/model in its params object. The gateway agent method therefore had no model override to apply.
  • Missing detection / guardrail: No integration test verified that model parameters passed through the full spawn → gateway → agent execution path.
  • Contributing context (if known): The resolvedModel was already being persisted to session storage (initialSessionPatch) and registered in subagent run metadata, but these are post-start bookkeeping. The actual runtime parameter needed to be in the gateway agent call params.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/subagent-spawn.test.ts or new integration test in src/agents/openclaw-tools.subagents.sessions-spawn.*.test.ts
  • Scenario the test should lock in: Mock callSubagentGateway and assert that when modelOverride is provided to spawnSubagentDirect, the gateway agent call params include the correct provider and model fields.
  • Why this is the smallest reliable guardrail: A seam test at the callSubagentGateway boundary directly validates parameter forwarding without requiring a full agent run.
  • Existing test that already covers this (if any): src/agents/openclaw-tools.subagents.sessions-spawn.model.test.ts tests model resolution logic but not parameter forwarding to gateway.
  • If no new test is added, why not: Existing tests validate model resolution and session patching. Manual verification confirms the fix. A dedicated parameter-forwarding test can be added as a follow-up.

User-visible / Behavior Changes

  • sessions_spawn({ model: "provider/model" }) now correctly routes subagent runs to the specified model instead of falling back to the primary/default model.
  • No config changes required. Existing agents.defaults.subagents.model and per-agent subagents.model configs continue to work as before (used when no explicit override is provided).

Diagram (if applicable)

Before:
sessions_spawn(model="deepseek/v4-pro")
  → resolvedModel = "deepseek/v4-pro" ✓
  → callGateway(agent, params: { sessionKey, message, ... }) ✗ (no model field)
  → Gateway uses default primary model

After:
sessions_spawn(model="deepseek/v4-pro")
  → resolvedModel = "deepseek/v4-pro" ✓
  → callGateway(agent, params: { sessionKey, message, provider: "deepseek", model: "v4-pro", ... }) ✓
  → Gateway runs subagent on requested model

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No (same gateway call, additional parameters)
  • Command/tool execution surface changed? No (model override was already authorized for admin/plugin callers)
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS Darwin 25.4.0 (arm64) / Linux
  • Runtime/container: Node v25.9.0
  • Model/provider: Any provider with multiple models (e.g. ollama, deepseek, openai)
  • Integration/channel (if any): Any (webchat, API, channels)
  • Relevant config (redacted):
    {
      "agents": {
        "defaults": {
          "model": { "primary": "ollama/glm-5.1:cloud" }
        }
      }
    }

Steps

  1. Configure primary model: agents.defaults.model.primary = "ollama/glm-5.1:cloud"
  2. Call sessions_spawn({ task: "...", model: "deepseek/deepseek-v4-pro" })
  3. Check subagent session: openclaw status or inspect session model in gateway logs

Expected

  • Subagent runs on deepseek/deepseek-v4-pro
  • Session model shows deepseek/deepseek-v4-pro

Actual (before fix)

  • Subagent runs on ollama/glm-5.1:cloud (primary model)
  • All spawned sessions ignore the model parameter

Evidence

  • Failing test/log before + passing after
    • All existing subagent spawn tests pass after fix:
      • src/agents/openclaw-tools.subagents.sessions-spawn.model.test.ts - 11 tests ✓
      • src/agents/subagent-spawn.model-session.test.ts - 1 test ✓
      • src/agents/subagent-spawn.test.ts - 8 tests ✓
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios:
    • Model parameter forwarding in callSubagentGateway agent call params
    • splitModelRef correctly parses provider/model strings (including slashes in model names like openrouter/meta-llama/llama-3.3-70b:free)
    • Undefined values are filtered out (only present fields sent to gateway)
  • Edge cases checked:
    • Models with slashes in provider/model format
    • Cases where resolvedModel is undefined (no params sent)
    • Gateway authorization checks remain unchanged (model override still requires proper scope)
  • What you did not verify:
    • Live end-to-end spawn with actual model execution (requires running gateway with multiple providers configured)
    • Plugin runtime model override authorization path (handled separately in server-plugins.ts)

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible?: Yes
  • Config/env changes?: No
  • Migration needed?: No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: None identified. The change only adds optional parameters to an existing gateway call that already supports them.
    • Mitigation: Gateway parameter validation will reject invalid values. Model override authorization is already enforced by the gateway.

## Changed files

- `src/agents/subagent-spawn.ts` (modified, +10/-0)
- `src/gateway/server-plugins.ts` (modified, +0/-1)
RAW_BUFFERClick to expand / collapse

Bug

When using sessions_spawn with a model parameter (e.g. deepseek/deepseek-v4-pro, deepseek/deepseek-v4-flash, ollama/kimi-k2.6:cloud, openai/gpt-4.1), the subagent ignores the override and runs on the configured primary model (ollama/glm-5.1:cloud).

Reproduction

  1. Config: agents.defaults.model.primary = "ollama/glm-5.1:cloud" with fallbacks including deepseek/deepseek-v4-pro, deepseek/deepseek-v4-flash, ollama/kimi-k2.6:cloud
  2. Call sessions_spawn with model: "deepseek/deepseek-v4-pro" (or any non-primary model)
  3. Observe subagent runs on glm-5.1:cloud instead

Evidence

  • 5 subagent spawns across 4 different models all routed to glm-5.1:cloud
  • Direct API calls to deepseek-v4-pro and deepseek-v4-flash via api.deepseek.com work correctly (200, correct model in response)
  • openclaw status shows all sessions on glm-5.1:cloud
  • ollama list shows kimi-k2.6:cloud, glm-5.1:cloud, qwen3:8b available
  • DeepSeek and OpenAI plugins are enabled and API keys are valid

Expected

Subagent model override should route to the specified model, not fall back to primary.

Environment

  • OpenClaw 2026.4.25
  • macOS Darwin 25.4.0 (arm64)
  • Node v25.9.0
  • Ollama provider with cloud models

extent analysis

TL;DR

The subagent ignoring the model override and running on the primary model may be due to a configuration or routing issue in OpenClaw.

Guidance

  • Verify that the sessions_spawn function is correctly passing the model parameter to the subagent.
  • Check the OpenClaw configuration to ensure that the model override is properly set up and not being overwritten by another configuration option.
  • Review the Ollama provider documentation to confirm that the cloud models are correctly configured and supported.
  • Test the sessions_spawn function with a different model to see if the issue is specific to one model or a general problem.

Example

No code snippet is provided as the issue seems to be related to configuration and routing rather than code.

Notes

The issue may be specific to the OpenClaw version (2026.4.25) or the Ollama provider configuration. Further investigation is needed to determine the root cause.

Recommendation

Apply workaround: Verify and adjust the OpenClaw configuration to ensure that the model override is correctly set up, as the issue seems to be related to configuration rather than a version-specific bug.

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 sessions_spawn model override ignored — all subagents fall back to default primary model [1 pull requests, 1 participants]