jcode icon indicating copy to clipboard operation
jcode copied to clipboard

Feature Request: Support per-worker model in swarm spawn

Open lumenfield opened this issue 2 months ago • 3 comments

Problem

Current behavior:

  • /swarm spawn "agent" model=some-model ignores the model= parameter
  • All spawned workers use swarm_model from config.toml
  • This makes it impossible to assign different models to different agents

Expected behavior:

  • /swarm spawn "agent" model=some-model should use some-model for that worker
  • swarm_model should only be used as fallback when model= is not specified

Use Case

We have 6 agents with different model requirements (v6.2 binding table):

Agent Required Model Provider
明镜 (coordinator) agnes-2.5-flash agnes-ai-direct
明德 agnes-2.5-flash agnes-ai-direct
明品 agnes-2.5-flash agnes-ai-direct
明码 cohere/north-mini-code:free openrouter
明真 nvidia/nemotron-3-ultra-550b-a55b:free openrouter
明察 nvidia/nemotron-3-ultra-550b-a55b:free openrouter

Current limitation forces all agents to use agnes-2.5-flash, wasting free models and reducing quality for code/review tasks.

Proposed Solution

Modify resolve_swarm_spawn_selection to:

  1. Check if model= parameter is explicitly provided
  2. If yes, use the provided model
  3. If no, fallback to swarm_model from config

References

  • Issue #1156: "model= parameter being ignored is expected"
  • Commit b76f96561: fix(swarm): make worker model operator-controlled

lumenfield avatar Sep 11 '26 00:09 lumenfield

I agree with the proposed behavior. The model= argument should take precedence over the global swarm_model setting.

Proposed fix

Update resolve_swarm_spawn_selection so model resolution follows this order:

  1. If /swarm spawn includes an explicit model=<model>, use that model for the spawned worker.
  2. Otherwise, use swarm_model from config.toml as the fallback.
  3. Preserve the existing behavior when neither is specified.

Conceptually:

def resolve_swarm_spawn_selection(..., model=None, ...):
    if model is not None:
        worker_model = model
    else:
        worker_model = config.swarm_model

    return ..., worker_model

The important part is that the explicitly supplied model= value must survive the spawn-selection/resolution path instead of being overwritten by swarm_model.

Expected behavior

For example:

/swarm spawn "明德" model=agnes-2.5-flash
/swarm spawn "明码" model=cohere/north-mini-code:free
/swarm spawn "明真" model=nvidia/nemotron-3-ultra-550b-a55b:free

Each worker should retain its requested model independently.

While:

/swarm spawn "agent"

should continue to use:

swarm_model = "..."

as the fallback.

Suggested tests

I would add regression tests covering at least:

  • explicit model= overrides swarm_model
  • missing model= falls back to swarm_model
  • different workers spawned from the same swarm can use different models
  • an explicitly provided model is not overwritten during worker/session creation

This also keeps the configuration backwards-compatible while making the CLI's model= parameter actually functional for per-worker model selection.

pradfer123 avatar Sep 11 '26 03:09 pradfer123

Per-worker model overrides are already restored by https://github.com/1jehuang/jcode/commit/e41c83468: an explicit swarm-tool model overrides agents.swarm_model, with the configured value used only as fallback. All 13 focused routing tests passed in this review. Note that /swarm spawn is not current TUI syntax. Ask the agent to call the swarm tool with action: "spawn", a label, and model, or use model: "inherit" to bypass the configured pin. Update the serving daemon as well as the client. If the actual tool call still loses its model, please share its redacted arguments and child route metadata.


— Jcode agent (automated triage), on behalf of @1jehuang

1jehuang avatar Sep 13 '26 01:09 1jehuang

Subject: 确认:per-worker model override 已由 e41c83468 实现,请求 close

We confirmed the feature in our STOS swarm-prompt model-binding table (v8.x): explicit model= in /swarm spawn overrides agents.swarm_model, with the configured value used only as fallback. This matches your 09-13 reply and the restored behavior in e41c83468.

Request: close this issue as implemented. The open question you raised about /swarm spawn (slash-command channel) is out of scope for our use case; we use the MCP swarm tool with explicit model args.

(Verified by STOS 明镜 coordinator, jcode v0.87.1 + e41c83468.)

lumenfield avatar Sep 28 '26 21:09 lumenfield