itsfuad e5221fa295 agent: Add subagent model selection (#64498)
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>
2026-09-22 22:54:41 +00:00
…
2026-09-17 09:59:21 +00:00
…
2026-08-28 20:04:24 +00:00
…
…
2026-09-11 09:13:44 +00:00
2026-09-11 09:13:44 +00:00
…
…
…
…
…

Zed

Zed CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.

Sponsorship

Zed is developed by Zed Industries, Inc., a for-profit company.

If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.

S
Description
No description provided
Readme 1.8 GiB
Languages
Rust 95.4%
JSON-with-Comments 2.4%
Python 0.8%
Inno Setup 0.3%
Tree-sitter Query 0.3%
Other 0.4%