#6875: test: add coverage for sessions_spawn model + agentId (#6817)
gateway
agents
Cluster:
Model Management Enhancements
## Summary
Adds regression tests for issue #6817 to verify that `sessions_spawn` correctly applies explicit model overrides even when `agentId` is provided.
## Test Coverage
Three new tests:
1. **`sessions_spawn uses explicit model even when agentId is also provided`**
- Passes both `model: "openrouter/deepseek/deepseek-chat"` AND `agentId: "research"`
- Verifies `sessions.patch` receives the explicit model, not the agent's `subagents.model`
2. **`sessions_spawn explicit model overrides global subagents.model default`**
- Verifies explicit model takes precedence over `agents.defaults.subagents.model`
3. **`sessions_spawn applies model when only task, model, and label are provided`**
- Baseline test for the "working" case per the issue
## Results
All tests pass.
This confirms that the `sessions_spawn` tool correctly:
- Extracts the explicit model from params
- Calls `sessions.patch` with the correct model
- Prioritizes explicit model over config defaults
## Implications for #6817
Since the tool-level code works correctly, the bug likely exists elsewhere:
1. **`sessions.patch` handler** — Model may not be persisted correctly
2. **`agent` method** — May not read `modelOverride` from the session entry
3. **Race condition** — Between `sessions.patch` completing and `agent` reading the session
4. **Model allowlist** — Silent rejection if the model isn't in the agent's allowlist
The tests narrow down the investigation area for whoever picks up the fix.
Refs: #6817
---
🤖 *Built together with Claude. Fully tested, code reviewed and understood.*
Most Similar PRs
#21088: fix: sessions_sspawn model override ignored for sub-agents
by Slats24 · 2026-02-19
73.1%
#10608: fix(agents): honor spawn model override in gateway and session spaw...
by 1kuna · 2026-02-06
72.9%
#19328: Fix: preserve modelOverride in agent handler (#5369)
by CodeReclaimers · 2026-02-17
72.7%
#16247: feat(agents): declarative agent definitions for sessions_spawn
by zerone0x · 2026-02-14
71.5%
#21556: fix(agents): graceful fallback when spawned model is not in allowlist
by irchelper · 2026-02-20
71.0%
#13376: fix: pass model directly to agent for sub-agent runs
by jrbobbyhansen-pixel · 2026-02-10
70.9%
#16964: test: add regression tests for sub-agent session path resolution
by StressTestor · 2026-02-15
70.1%
#13331: feat(sessions_spawn): add sessionKey param to reuse sub-agent sessions
by Be1Human · 2026-02-10
70.0%
#19774: Allow explicit model allowlist entries missing from provider catalogs
by harshang03 · 2026-02-18
69.5%
#20712: fix(subagents): prioritize agent runtime default model over global ...
by sourcesavant · 2026-02-19
68.5%