Swarm agents use hardcoded/random model instead of inheriting current session model
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Problem
When spawning swarm agents via swarm spawn, the model selection logic in resolve_swarm_spawn_selection (crates/jcode-app-core/src/server/comm_session.rs) falls back to a hardcoded or seemingly random model when no explicit agents.swarm_model config pin is set and no per-spawn model parameter is passed.
Specifically, when agents.swarm_model is unset and the spawn request does not include a model field, the function calls inherit_coordinator_selection(&coordinator) which should inherit the coordinator's model. However, the coordinator identity resolution (resolve_coordinator_spawn_identity) can return None for the model field in certain edge cases, causing the spawned agent to fall back to whatever the provider's default model is — often an OpenAI model like gpt-5.5 or a random provider default, regardless of what model the user is currently using in their session.
Expected behavior
When no swarm model override is configured, spawned swarm agents should inherit the current session's model by default. The user should be able to explicitly choose the swarm model from the /model picker (not just from the less discoverable /agents command).
Actual behavior
The swarm model defaults to a hardcoded provider default instead of the current model. The /model picker does not expose any way to configure the swarm model, making the agents.swarm_model config the only discovery path — which most users never find.
Reproduction
- Start a session with a non-default model (e.g. Claude Sonnet)
- Spawn a swarm agent without passing a
modelparameter - Observe the spawned agent may use a different model (e.g. GPT-5.5) instead of Claude Sonnet
Root cause
In resolve_swarm_spawn_selection, the inherit_coordinator_selection fallback relies on coordinator.model which can be None. When it is None, provider_key_for_spawn_model resolves to the provider's hardcoded default, not the user's active session model.
Proposed fix
- Ensure
resolve_coordinator_spawn_identityalways returns the active session's model, notNone - Add a
Ctrl+Sshortcut in the/modelpicker to open the swarm model sub-picker, making swarm model configuration discoverable from the main model selection flow - Default to inheriting the current model when no swarm model is chosen
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crates/jcode-app-core/src/server/comm_session.rs, tracing resolve_swarm_spawn_selection and resolve_coordinator_spawn_identity to reproduce how a missing coordinator model reaches the provider default. Then inspect the /model picker flow for the proposed Ctrl+S swarm-model entry point. Done means an unconfigured swarm inherits the active session model and the picker exposes swarm-model selection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- ai, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 66/100