Commit Graph

31 Commits

Author SHA1 Message Date
Ben Brandt 39b5329322 acp_thread: Separate submission receipts from session activity (#64930)
Separate prompt submission from session activity without enabling v2
transport. A receipt acknowledges acceptance; it does not mean the agent
has finished working.

- Select an optional, session-bound receipt capability before sending.
Existing v1/native connections retain completion-based prompt behavior.
- Give submissions and foreground activity separate owners. Submission
records own response tasks, IDs, echo correlation, and recoverable
content; activity owns Running/RequiresAction/Idle state, timing,
generations, and cancellation waiters.
- Keep receipt-driven pending text outside the transcript. Only agent
echoes create canonical user messages, with receipt/echo correlation
working in either order. Pending and failed submissions have recovery
controls; restoring an editable copy keeps the original until explicit
Discard.
- Carry generation, duration, and stop reason in completion events.
Stale events cannot advance a newer activity's queue or display old
errors. Timers also reconcile correctly when Running and Idle arrive
before the UI observes either transition.
- Preserve legacy completion/cancellation semantics while running
completion directly in the record-owned task, removing a redundant
task/channel bridge. Native subagent and eval consumers explicitly
require completion rather than accepting a receipt as a finished run.

## Review guide

This is a cross-layer lifecycle change, not a wire adapter. Suggested
review order:

1. [Submission and activity
ownership](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/acp_thread/src/submission.rs#L98):
retention, echo correlation, task ownership, and idle waiters.
2. [Core
settlement](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/acp_thread/src/acp_thread.rs#L3910)
and [legacy turn
completion](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/acp_thread/src/acp_thread.rs#L5765):
receipt settlement must not finish activity; cancellation still waits on
the transport task.
3. [UI activity
reconciliation](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/agent_ui/src/conversation_view/thread_view.rs#L1446)
and
[recovery](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/agent_ui/src/conversation_view/thread_view.rs#L1533):
queue/error ownership, batched updates, and recoverable originals.

The receipt capability defaults to absent. Existing agents still use
optimistic v1 messages and completion-based send/command/retry behavior.
Legacy refusal, pending-action cleanup, and native subagent behavior
retain their compatibility paths.

Delta Thread:
https://delta.dev/trunk/join/thread_01m2swv74pzp4c6xk46sh19fmk#s=MYAgERzq

Release Notes:

- N/A
2026-09-30 08:42:44 +00:00
Ben Brandt 986828d157 acp_thread: Add shared tool-call state and diff previews (#64875)
Review Thread:
https://delta.dev/trunk/join/thread_01m2swv74pzp4c6xk46sh19fmk#s=pVggqzly

Normalize legacy ACP tool reports and SDK v2 tool patches into one
shared `ToolCall` model, preserving protocol source separately from
local decisions and rendered views.

- Retain reported kind/status, first-class name, metadata, and complete
tool-content sources, including unknown v2 values and envelope metadata.
- Keep authorization ownership and local outcomes separate from reported
status. Support omitted/null/value patches without changing legacy
permission-continuation behavior.
- Preserve the status-before-content-validation contract: invalid
presentation cannot roll back a terminal report or leave its permission
unresolved.
- Render supported v2 patches with read-only diff editors using `diffy`.
Preserve sparse hunk coordinates, multi-file structure,
additions/deletions, and original source without reading or modifying
workspace files. Accept standalone unified patches and unambiguous bare
hunks; retain explicit fallback and export text for unsupported input.
- Keep native live diffs separate from protocol snapshots, preserve
render identity on metadata-only updates, and align patch
expansion/search with visible authorization content.

This adds the shared model and presentation boundary; it does **not**
enable v2 transport negotiation or change prompt lifecycle. Existing
v1/native adapters continue to work. The existing
one-active-authorization-per-tool policy is unchanged.

Release Notes:

- N/A
2026-09-28 15:53:24 +00:00
Ben Brandt 3794e5e979 acp_thread: Add keyed message updates (#64773)
Stacked on #64765, with `benbrandt/acp-message-updates` as the base
branch.

- Add typed SDK v2 user-message, assistant-message, and thought upserts,
plus keyed chunk appends, using the existing transcript records.
- Keep legacy optional-ID adjacency and optimistic echo behavior
separate. Keyed records retain their first-seen positions; conflicting
message kinds fail before mutation.
- Apply omitted/null/value content and message metadata independently.
Full snapshots replace content; later chunks append. Chunk-envelope
metadata does not patch message metadata.
- Reconcile rendered text runs and preserve compatible Markdown/image
entities. Replacing a message discards only its superseded streaming
cursor.
- Keep read-only user messages synchronized, including empty snapshots,
without resetting selection on metadata-only or identical updates. A
compact source-change token avoids caching another payload copy.

This does not select v2 connections or change prompt acceptance and
turn-completion semantics. Keyed lookup scans the existing records;
there is no second transcript or maintained ID index.

Release Notes:

- N/A
2026-09-28 09:26:37 +00:00
Mikayla Maki 975845875b language_model: Make LanguageModel plain data served by its provider (#64750)
`LanguageModel` used to be a trait object. Each provider implemented it
on a private struct that bundled the model's metadata with the client,
credentials, rate limiter and a snapshot of its config, and consumers
held `Arc<dyn LanguageModel>` or a `ConfiguredModel { provider, model }`
pair.

This makes `LanguageModel` plain data: a `Clone + Debug + PartialEq`
struct with the same getters the trait had, held by value everywhere.
`ConfiguredModel` is gone. Providers serve requests themselves:
`LanguageModelProvider` gains `stream_completion` (plus the text/tool
helpers, `count_input_tokens`, `compact` and `api_key`), each taking
`&LanguageModel`. Senders look the provider up with
`LanguageModelRegistry::provider_for_model` when they send.

Every provider now has one lookup that decides which models it offers
and with what config. `provided_models` and the defaults are built from
it, and each request resolves the model's current config from it by id.
There are no per-model or per-request objects. A model the provider no
longer offers fails with a new, non-retried
`LanguageModelCompletionError::ModelUnavailable` instead of being served
from a stale snapshot.

This prepares for opening provider-side sessions over an append-only
message log. With models as plain data and requests on the provider, a
session can be one generic type rather than one per provider, and
deciding whether a session can be reused becomes a value comparison.

## Suggested reading order

1. `crates/language_model/src/language_model.rs` (the struct and
provider trait), `registry.rs`, and `fake_provider.rs`.
2. One representative provider:
`crates/language_models/src/provider/anthropic.rs`.
3. Providers that deviate: `bedrock.rs`, `llama_cpp.rs`,
`open_router.rs`, `crates/copilot_chat`, `crates/language_models_cloud`,
`crates/openai_subscribed`, `crates/x_ai_subscribed`.
4. Callers: `crates/agent/src/thread.rs`, then `agent_ui`, `git_ui`,
`sidebar`. Most of the remaining diff is tests.

## Behavior changes worth reviewing

- Rate limiting is one concurrency limit per model id, shared across the
app, with a limit of 16. Before, each model instance had its own limit
of 4.
- `Thread::refresh_model` re-selects a thread's model by id when its
provider reports a state change, so capability changes (for example a
llama.cpp model finishing loading) reach the thread.
- Bedrock resolves auth once per request for both Converse and Mantle,
off the foreground thread, with the SDK's default 5s credential load
timeout. Expiring credentials (SSO, STS, credential processes) are
cached until shortly before expiry and dropped on any auth change;
credentials without an expiry are re-read every request, so credential
files rewritten by external tools take effect immediately. Mantle
credential resolution now goes through Zed's HTTP client, like Converse.
- Bedrock honors `AWS_BEARER_TOKEN_BEDROCK`, then `AWS_BEARER_TOKEN`
(even if empty), over AWS credentials unless an API key is configured in
Zed, matching the SDK. This now applies to Mantle too, so users with
IAM/profile auth and one of these variables set must unset it (not empty
it) for Mantle to use IAM/profile.
- A Bedrock Mantle model with the same id as a Converse model replaces
it, so each id is offered and served once.
- OpenRouter and Vercel AI Gateway report default-model metadata from
the same lookup they serve requests from.
- A request for a model that has left a provider's list (for example
after signing out of Copilot or Zed) returns `ModelUnavailable`. Commit
message generation shows this as an error instead of doing nothing.

## Tests

`FakeLanguageModel` is gone. `FakeLanguageModelProvider` serves any
model id and owns every request sent to it; tests answer a request by
naming its model (`send_last_text(&model, ...)`, `send_text(&model,
&request, ...)`), so requests to different models can't be confused.

Tested: `agent` (753 tests), `language_model`, `language_models`,
`language_models_cloud`, `copilot_chat`, `openai_subscribed` and
`x_ai_subscribed`, plus `cargo check --workspace --tests`. The
`agent_ui`, `git_ui` and `sidebar` test binaries type-check but were not
run locally because of a linker issue in my environment; CI will cover
them. Providers have not yet been exercised against live services.

Release Notes:

- N/A
2026-09-25 17:08:34 +00:00
Ben Brandt df673c1b85 acp_thread: Preserve ordered mixed content in agent messages (#64456)
Preserve ordered mixed content in agent messages without disrupting text
streaming for existing native/v1 agents. The previous single-block
reduction could replace images with placeholders or lose non-text
content as subsequent chunks arrived.

- Introduce [ordered message display
content](https://github.com/zed-industries/zed/blob/929fba3e16f7a378eb1dca3d85ac2f1df2b902c6/crates/acp_thread/src/acp_thread.rs#L1500),
reusing adjacent text entities while retaining image/resource-preview
boundaries.
- Update rendering, text search, response copy/export, Mermaid cache
invalidation, and CLI output to visit the collection.
- Use block-local context menus and existing Markdown getters so copy
commands target the clicked part rather than another part's cached
state.
- Keep existing link/mention formatting, resource-button and blob-label
search behavior, compact prompt mentions, and original user-message
chunks.
- Preserve the separator between a leading resource link and subsequent
direct or streamed text.

Release Notes:

- N/A
2026-09-21 09:24:15 +00:00
tidely 6fff327a90 Bump Rust to 1.98.1 (#63010)
# Objective

- Bump Rust to 1.98.1

Release Notes:

- N/A
2026-09-11 09:13:44 +00:00
Cole Miller db10a8dd73 fs: Refactor the code around GlobalWatcher to be more testable (#63894)
This is a pure refactoring PR to make our FS watching code more
testable. It does two things:

1. Make the `GlobalWatcher` be owned by `RealFs` or `FakeFs` instead of
being a process-wide global.
2. Delete `FakeWatcher` and its `Watcher` implementation, and instead
mock the notify crate itself in `FakeFs` tests via the existing
`WatchBackend` trait. Now all our FS watching code down to the notify
boundary runs the same in tests and production.

Release Notes:
- N/A
2026-09-07 19:01:41 +00:00
Kirill Bulatov 1271f8b0e8 Bump rustc to 1.97 (#62395)
Release Notes:

- N/A
2026-08-09 22:29:52 +00:00
Anant Goel a923597341 Fix agent terminal in headless eval sandbox (#59969)
# Objective

Fix the agent `terminal` tool in headless eval environments. In the eval
sandbox, terminal commands failed before the shell ran with `IOError:
Not a tty (os error 25)` because PTY setup attempted to acquire a
controlling terminal.

## Solution

- Add a `terminal::HeadlessTerminal` global that is set by `eval_cli`
only.
- When headless mode is enabled, run terminal task commands as plain
subprocesses with piped stdout/stderr instead of opening a PTY.
- Pump subprocess output through the existing terminal emulator/event
channel so output capture, completion, and task killing keep working.
- Build ACP terminal commands non-interactively in headless mode.
- Keep the normal editor terminal path unchanged when the global is
unset.
- Handle non-PTY output edge cases by preserving split CRLF sequences
and avoiding an indefinite wait if subprocess exit-status polling
errors.

## Testing

- `cargo fmt --all`
- `cargo test -p util non_interactive_omits_interactive_flag`
- `cargo test -p terminal test_no_pty_task_terminal_captures_output`
- `cargo test -p terminal test_convert_lf_to_crlf_preserves_split_crlf`
- `cargo test -p terminal test_write_output`
- `cargo check -p eval_cli`
- `git --no-pager diff --check`

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed the agent terminal tool failing with "Not a tty" in
headless/eval environments
2026-06-29 15:58:53 +00:00
Ben Brandt 70fd3c5774 acp: Handle acp message ids when we get them (#59927)
This separates the two user-message identities we currently need in
agent threads:

- `protocol_id`: the ACP `messageId` used to group or split streamed
message chunks from ACP agents.
- `client_id`: the Zed-generated user message ID used by the native
agent for truncate, rewind, edit/regenerate, checkpoints, token usage,
and persistence.

The main behavior change is that ACP protocol message IDs now affect
message merging/rendering without leaking Zed-native client IDs into ACP
agents by default. Agents that can accept Zed-generated user message IDs
opt into that path through `AgentSessionClientUserMessageIds`, which
owns both ID generation and prompt submission. The native Zed agent
implements that capability; normal ACP agents continue through the
protocol-only `prompt` path.

In ACP v2 we'll have a mechanism for getting user message replays that
will allow the agent to adequately generate it's own opaque id that we
can then use for these other capabilities. But for now, this split at
least makes sure we keep the two concepts distinct.

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
2026-06-29 07:21:09 +00:00
Anant Goel 10f501d700 eval_cli: Add remote benchmark orchestration (#59802)
Summary:

- Add the `zed-eval` Python CLI for Modal/Harbor/Pier benchmark
orchestration, including content-addressed remote builds, run/suite
management, reporting, rejudge, baseline, and cleanup workflows.
- Extend `eval-cli` for remote evals with provider/model overrides and
step/tool-call metrics in `result.json`.
- Add install/source-run helper scripts so `zed-eval` can be installed
or run from the checkout without manually setting `PYTHONPATH`.
- Harden the remote harness wrappers around exit-code preservation,
archive extraction, custom secret wiring, and Harbor/Pier option parity,
with regression coverage.

Testing:

- Using the CLI for two weeks
- `PYTHONPATH=crates/eval_cli python3 -m compileall -q
crates/eval_cli/zed_eval`
- `uv run --project crates/eval_cli/zed_eval python -m unittest discover
-s crates/eval_cli/zed_eval/tests`
- `bash -n crates/eval_cli/script/install-zed-eval
crates/eval_cli/script/zed-eval`
- `cargo check -p eval_cli`
- `cargo fmt --package eval_cli -- --check`
- `cargo test -p eval_cli --no-run`
- `./script/clippy -p eval_cli`

Release Notes:

- N/A
2026-06-24 15:32:41 +00:00
Ben Brandt 8ba35e5eac acp: Update agent client protocol crate to 0.15.0 (#59593)
We finally have a cancellation mechanism to use! Made the non
side-effectful handlers stop their work if we get a cancel request
notification.

Release Notes:

- N/A
2026-06-22 09:04:29 +00:00
Ben Brandt 5efd6f68c7 git_ui: Make git_ui call support optional (#58413)
Broke the headless builds for evals. Open to cleaner ways of doing
this...

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
2026-06-03 13:18:45 +00:00
MartinYe1234 aa6062edaf Stop loading deprecated agent rules (#57844)
Summary:

- Stop loading persisted default Zed Rules into native agent project
context.
- Remove legacy user-rules rendering from agent system prompt templates.
- Keep Skills and project rules file support unchanged.

Tests:

- cargo test -p agent
test_system_prompt_does_not_render_legacy_zed_rules_section --lib
- cargo test -p prompt_store test_empty_skills_sets_has_skills_false
- cargo test -p prompt_store
test_project_context_does_not_filter_by_budget

Closes AI-325
Release Notes:

- Fixed deprecated Rules being automatically included in new agent
requests.
2026-05-27 16:21:30 +00:00
Ben Brandt 4557ad7ad1 eval_cli: Initialize themes in eval headless mode (#57139)
Also fix patch generation

Release Notes:

- N/A
2026-05-19 11:29:00 +00:00
Ben Brandt 5aeb8a7e0f eval_cli: Wait for model discovery (#57038)
Given the model list is dynamic now, we need a wait

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
2026-05-18 08:41:02 +00:00
Ben Brandt 9a679b3226 eval_cli: Set global filesystem in eval CLI init (#55862)
Some dependency started requiring this, so fixing some runtime errors.

Release Notes:

- N/A
2026-05-06 09:35:43 +00:00
Ben Brandt 7a34bc059e eval_cli: Update eval_cli toolchain and pin harbor (#55768)
Move `git_ui` to `agent_ui` test dependencies
and bump the eval CLI Docker image to Rust 1.95.0 while pinning
the Python `harbor` dependency to 0.6.4

Release Notes:

- N/A
2026-05-05 13:40:58 +00:00
Ben Brandt b4a96f9c14 eval_cli: Fixes for termbench (#55762)
Release Notes:

- N/A
2026-05-05 12:32:58 +00:00
Ben Brandt 58e2b7ecdd acp: Use new Rust SDK (#52997)
Testing out Niko's new SDK design

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable


Release Notes:

- N/A
2026-04-22 15:02:57 +00:00
Jakub Konka 29609d3599 language_model: Decouple from Zed-specific implementation details (#52913)
This PR decouples `language_model`'s dependence on Zed-specific
implementation details. In particular
* `credentials_provider` is split into a generic `credentials_provider`
crate that provides a trait, and `zed_credentials_provider` that
implements the said trait for Zed-specific providers and has functions
that can populate a global state with them
* `zed_env_vars` is split into a generic `env_var` crate that provides
generic tooling for managing env vars, and `zed_env_vars` that contains
Zed-specific statics
* `client` is now dependent on `language_model` and not vice versa

Release Notes:

- N/A
2026-04-02 17:06:57 -03:00
Ben Brandt 76c6004b27 Remove text thread and slash command crates (#52757)
🫡

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Removed legacy Text Threads feature to help streamline the new agentic
workflows in Zed. Thanks to all of you who were enthusiastic Text Thread
users over the years ❤️!

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
2026-03-31 17:55:05 +02:00
Mikayla Maki 8b0d49f474 Add existing user agent onboarding flow (#52787)
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A
2026-03-31 01:39:47 +00:00
Ben Brandt 0d5504e3d4 eval_cli: Make things a bit more resilient to different Docker envs (#52731)
Release Notes:

- N/A
2026-03-30 13:18:22 +00:00
Piotr Osiewicz b59ae5cf81 Bump Rust version to 1.94 (#51086)
Closes #ISSUE

Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- [ ] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A
2026-03-30 09:06:59 +00:00
Ben Brandt 24ea5e98da eval_cli: Simplify build setup for more datasets (#52686)
Cleans up build setup and simplifies it a bunch so that we can use the
binary in more eval docker containers

Release Notes:

- N/A
2026-03-29 20:58:50 +00:00
Ben Brandt 1f5d280870 eval_cli: Improve setup for the eval_cli args (#52209)
## Context

Fixes some issues I ran into when running this on a remote machine.

## Self-Review Checklist

<!-- Check before requesting review: -->
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
2026-03-24 11:53:08 +00:00
Bennet Bo Fenner 015225196d Store ACP thread metadata (#51657)
Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A

---------

Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-03-16 17:23:02 +01:00
Bennet Bo Fenner f4b04af3dc agent: Allow NativeAgent to work with multiple projects (#51202)
This removes the assumption that one project <-> one native agent. The
native agent now maintains a project per session. We don't make use of
this right now, but it will come in handy once we start sharing ACP
connections globally.

Release Notes:

- N/A
2026-03-10 17:04:48 +01:00
Neel dc0e41f834 Refresh LLM API token on organization change (#50931)
Emit client-side organization changed events through
`RefreshLlmTokenListener` so it produces the same `RefreshLlmTokenEvent`
used for server-pushed `UserUpdated` messages.

This keeps token refresh fan-out in one place.

Closes CLO-383.

Release Notes:

- N/A

---------

Co-authored-by: Tom Houlé <tom@tomhoule.com>
2026-03-06 19:15:21 +00:00
Ben Brandt 2457e27437 eval: Add eval_cli crate (#50922)
Very much wip

Release Notes:

- N/A
2026-03-06 11:12:38 +00:00