1jehuang / 1jehuang/jcode

Swarm agents use hardcoded/random model instead of inheriting current session model

Open
#981 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-info triage: unclear
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

  1. Start a session with a non-default model (e.g. Claude Sonnet)
  2. Spawn a swarm agent without passing a model parameter
  3. 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

  1. Ensure resolve_coordinator_spawn_identity always returns the active session's model, not None
  2. Add a Ctrl+S shortcut in the /model picker to open the swarm model sub-picker, making swarm model configuration discoverable from the main model selection flow
  3. Default to inheriting the current model when no swarm model is chosen

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.