mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-23 17:10:37 +01:00
e5221fa295
Adds optional model selection to `spawn_agent`, allowing a newly spawned subagent to use a specific configured model. This is an additive change. Existing `spawn_agent` behavior remains unchanged when `model` is omitted: Zed continues to use the configured subagent model when one is set, otherwise the subagent inherits the parent model. The resulting selection order is: `explicit model override` → `configured subagent model` → `parent model` Explicit model IDs use the `provider/model-id` format returned by `list_agents_and_models`. When an explicit model is supplied, it is validated against the currently available models. If it is unavailable, the spawn fails instead of silently substituting another model. Resumed subagent sessions keep their original model, so `model` cannot be supplied together with `session_id`. This follows the model-selection use case discussed here: https://github.com/zed-industries/zed/discussions/60993#discussioncomment-18450658 The change also makes the active model visible in native subagent cards, including when the subagent happens to use the same model as its parent. ## Screenshot <img width="820" height="959" alt="Screenshot From 2026-09-19 22-53-26" src="https://github.com/user-attachments/assets/210db6e7-0068-45cc-aa96-f3a5aca3f90c" /> ## Implementation - Add an optional `model` field to `spawn_agent`. - Preserve the existing configured-subagent-model and parent-model fallback behavior when no explicit model is supplied. - Validate explicit model selections against currently available models. - Reject model overrides when resuming an existing subagent session. - Keep `list_agents_and_models` available independently of the create-thread feature flag so `spawn_agent` can use it for model discovery. - Allow native model discovery to work without the sibling-thread host, while still including external agents when that host is available. - Display the active model name in native subagent card headers. ## Testing Manually tested explicit model selection by first calling `list_agents_and_models`, then spawning five subagents concurrently with exact discovered model IDs: - `openai-subscribed/gpt-5.6-sol` - `openai-subscribed/gpt-5.6-luna` - `openrouter/inclusionai/ling-3.0-flash-vl:free` - `openrouter/nex-agi/nex-n2.5-mini:free` - `openrouter/nex-agi/nex-n2.5-pro:free` All five subagents completed successfully, returned distinct session IDs, and displayed their selected model names in the subagent cards. Also added coverage for: - forwarding an explicit model selection through `spawn_agent` - rejecting a model override when resuming a session - preserving the existing configured subagent model behavior when no override is provided - preserving parent-model fallback behavior - exposing `list_agents_and_models` independently of sibling-thread creation ## Self-Review Checklist - [x] I have reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks: none added - [x] The content adheres to Zed UI standards - [x] Tests cover the new and changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Added model selection for spawned subagents. --------- Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>