dc0bbb2b43d8a40fe0bd4664770cc4af4f907e9f
27
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
59d996d8db |
Add per-request model output limits (#64047)
## Stack - This PR: output-limit plumbing, based on `main`. - #64194: provider input counting and consent, based on this branch. - #64195: Copilot metadata and consumers, independently based on this branch. After this PR lands, rebase/retarget both children onto `main` as needed, especially after a squash merge. At split time, a synthetic merge of the two child heads exactly matched the saved pre-split source tree. PR1 has since consolidated overlapping tests without changing production code. ## Summary Part 1 of a three-PR split: add optional per-request `max_output_tokens`, forward it through provider payloads, and clamp it against known output limits. Unset requests preserve existing defaults. Unknown Copilot output metadata is not treated as a zero-token maximum when forwarding a cap. This PR also supplies the combined-window and native-capability interfaces used by downstream budget calculations. It does not add input-token counting, data-retention consent integration, or change Copilot prompt/context metadata, compaction thresholds, or tooltips. Those changes are split into two child PRs based on this branch. The net diff is 24 files, +438/-55. Forward narrowing commits preserve the original review history; there was no force-push. ## Test consolidation Eight overlapping standalone tests have been folded into existing conversion tests, preserving coverage of unset limits, explicit limits, clamping, and serialized payloads. Four distinct tests remain separate: request serialization compatibility, Copilot wire formats, DeepSeek conversion (no existing conversion suite), and hosted OpenAI normal-completion HTTP behavior. This cleanup changes no production Rust code. ## Validation - Latest run: 269 tests passed across anthropic, google_ai, open_ai, language_models, copilot_chat, and language_models_cloud. - Five extended existing tests failed when cap selection was temporarily broken and passed after restoration. No mutations remain. - Latest scoped script/clippy, formatting, and whitespace checks passed. Earlier split validation: - 229 tests passed across language_model_core, anthropic, open_ai, copilot_chat, and language_models_cloud. - Scoped script/clippy passed for copilot_chat, language_models_cloud, language_models, agent, and agent_ui. - Formatting and whitespace checks passed. - Permanent tests cover payload propagation, absent/explicit limits, unknown output metadata, direct and hosted native-compaction caps, and hosted OpenAI clamping. - No live provider requests were made for the split. ## Review notes The separately identified fixed/non-interleaved thinking-budget versus smaller output-cap concern remains open in this PR; it must not be hidden in the counting or metadata PRs. The README acknowledgment is retained for human review. Downstream applications using input counting must consume the counting child PR as well, not repin to this branch alone. Release Notes: - N/A |
||
|
|
28e52a2879 |
Send session headers on all OpenCode requests (#63702)
Fixes https://github.com/zed-industries/zed/issues/63672 OpenCode Go now requires the `x-opencode-session` header on every model request. Zed previously sent the header only when a request already had a thread ID, so inline assistance, terminal assistance, and other standalone requests could omit it and risk rejection. This change makes the OpenCode provider add the header to every request. Existing thread and assist session IDs are reused when available. Standalone requests receive a generated non-empty ID. Thread title and summary requests now carry the thread ID so related requests keep the same session scope. The change also adds tests for missing, empty, and invalid IDs, plus a wire-level test that verifies the header reaches the HTTP client. The provider test file stays separate so the implementation remains under 1,000 lines. Testing: - `cargo fmt --all -- --check` - Focused OpenCode, thread summary, and thread title tests - `cargo check -p agent_ui -p sidebar` - `GITHUB_ACTIONS=1 ./script/clippy -p language_models` - `git diff --check` Release Notes: - Fixed OpenCode Go requests that could fail when Zed omitted the session header. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev> Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com> |
||
|
|
8514ce3ba1 |
Unify language model event stream handling (#63520)
Closes https://github.com/zed-industries/zed/issues/63314 Closes https://github.com/zed-industries/zed/issues/42584 Follow-up to https://github.com/zed-industries/zed/pull/62652 Removes a lot of duplicated code in favor of throwing it into`language_core` as well as removing duplicate struct definitions that were only different because of entirely unused fields. Furthermore, improves error-messages so that these untagged enum errors are no longer a thing in an effort to make this more maintainable in the future. Lastly, includes a small but nice improvement changing a `Value` to a `RawValue` so that we don't have to clone for deserialization in that specific case. Release Notes: - Improved streaming for OpenAI-compatible providers. --------- Co-authored-by: Anant Goel <anant@zed.dev> |
||
|
|
5ed5bf95e5 |
Move language model stream mapping to background executors (#63241)
Language model event mappers run as part of lazy completion streams. Because these streams are polled on the main thread, repairing and parsing large streamed tool inputs can freeze the UI. This moves completion stream mapping to background executors. A bounded channel preserves event order and backpressure, while dropping the stream cancels its background task. The change covers all providers that perform this work. Release Notes: - Fixed UI hangs when language model providers stream large tool inputs. |
||
|
|
99f4c21c03 |
agent: OpenCode model updates (+6 Go, +7/-1 Zen, removed Free) (#61199)
Closes https://github.com/zed-industries/zed/issues/62559 Related discussion: https://github.com/zed-industries/zed/discussions/61160 # Objective Adding newly-released OpenCode models. Removing OpenCode Free models completely. ## Solution > [!TIP] > This pull request is **best reviewed commit-by-commit**! **OpenCode Go**: - added **Kimi K3** as per [[1]](https://github.com/anomalyco/models.dev/blob/89183a9646cf2fa30300f7203a5b4f2ca69d1374/providers/opencode-go/models/kimi-k3.toml) and [[2]](https://github.com/anomalyco/models.dev/blob/dev/models/moonshotai/kimi-k3.toml). Currently, the only supported reasoning level available is `Max` which was validated both with Models.dev data and OpenCode CLI. - added **Grok 4.5** as per [[1]](https://github.com/anomalyco/models.dev/blob/89183a9646cf2fa30300f7203a5b4f2ca69d1374/providers/opencode-go/models/grok-4.5.toml) and [[2]](https://github.com/anomalyco/models.dev/blob/89183a9646cf2fa30300f7203a5b4f2ca69d1374/models/xai/grok-4.5.toml) - added **Tencent Hy3** as per [[1]](https://github.com/anomalyco/models.dev/commit/b013d94872bb5993fad19ad35fadf74cb029516e) and [[2]](https://github.com/anomalyco/models.dev/blob/f63b5ce78dd78869faa0612353b1055f6608dc97/models/tencent/hy3.toml) - added **GPT 5.6 Luna** as per [[1]](https://github.com/anomalyco/opencode/pull/39812) and [[2]](https://github.com/anomalyco/models.dev/blob/dev/providers/opencode-go/models/gpt-5.6-luna.toml) - added **Qwen 3.8 Max** as per [[1]](https://github.com/anomalyco/models.dev/commit/403a7bdd43ac7daeadc8bb755eccabf66a0afb9d) and [[2]](https://github.com/anomalyco/opencode/commit/e9e747245681127c9f3e300aa8c46f2554fdb294) - added **GLM 5.3** as per [[1]](https://github.com/anomalyco/models.dev/blob/3876740bf4f0290e014bc85340e1dba34f0e99a7/models/zhipuai/glm-5.3.toml) and [[2]](https://github.com/anomalyco/models.dev/commit/94a1629610b579fd80f7c488f5e4e8d78c8b6883) and [[3]](https://github.com/anomalyco/opencode/pull/42518) **OpenCode Zen**: - added **Gemini 3.5 Flash Lite** as per [[1]](https://github.com/anomalyco/models.dev/blob/f63b5ce78dd78869faa0612353b1055f6608dc97/providers/opencode/models/gemini-3.5-flash-lite.toml) and [[2]](https://github.com/anomalyco/models.dev/blob/f63b5ce78dd78869faa0612353b1055f6608dc97/models/google/gemini-3.5-flash-lite.toml) - added **Gemini 3.6 Flash** as per [[1]](https://github.com/anomalyco/models.dev/blob/f63b5ce78dd78869faa0612353b1055f6608dc97/providers/opencode/models/gemini-3.6-flash.toml) and [[2]](https://github.com/anomalyco/models.dev/blob/f63b5ce78dd78869faa0612353b1055f6608dc97/models/google/gemini-3.6-flash.toml) - added **Gemini 3.7 Flash** as per [[1]](https://github.com/anomalyco/models.dev/pull/4632) and [[2]](https://github.com/anomalyco/models.dev/commit/b1810e30d7abb11af1092b51aa28cbafc2c440b8) and [[3]](https://github.com/anomalyco/opencode/pull/42390) and [[4]](https://github.com/anomalyco/opencode/pull/42393) - added **Claude Opus 5** as per [[1]](https://github.com/anomalyco/models.dev/commit/e3ae24cdd7fb524d73e1569ed1713991c5ba688c) and [[2]](https://github.com/anomalyco/models.dev/commit/342b5572a06735d0efa8c3c419589051199459d8) - added **Kimi K3** as per [[1]](https://github.com/anomalyco/opencode/commit/a9bebd36530dbab28c4644eb7b35b2b1460b8b90) and [[2]](https://github.com/anomalyco/models.dev/commit/38ccccc20d7d827f99d791d07cc4cedb8b4eec24) - added **Grok 4.6** as per [[1]](https://github.com/anomalyco/models.dev/commit/74789f5a02746cf6c40b75c342432a9d525c28b9) and [[2]](https://github.com/anomalyco/opencode/commit/d92d1e654bd1aa8ccb972b3059825314c1633eb8) and [[3]](https://github.com/anomalyco/models.dev/pull/4575) - added **Muse Spark 1.2** as per [[1]](https://github.com/anomalyco/models.dev/commit/fa03dca90bad225a09263ad6ad227c7f47d0172d) and [[2]](https://github.com/anomalyco/models.dev/blob/3876740bf4f0290e014bc85340e1dba34f0e99a7/models/meta/muse-spark-1.2.toml) and [[3]](https://github.com/anomalyco/opencode/pull/42508) - removed **Claude Opus 4.1** as per [[1]](https://github.com/anomalyco/models.dev/commit/6951484e985fe55646a741ccd3ca1d4b15008e3f) **OpenCode Free**: removed all the models and the whole concept of "OpenCode Free" from Zed. As confirmed [by an Anomaly employee on the OpenCode Discord](https://discord.com/channels/1391832426048651334/1394667004979445931/1537530485356363899), free models are now OpenCode-only since they got abused waaaaay too much by people. Testing shows that even with an active OpenCode Go subscription configured, I can't use Free models in Zed — both Big Pickle and DeepSeek V4 Flash Free failed to reply to a _"hello"_ message and instead returned a rate-limit error. A full removal of OpenCode Free from Zed was implemented in https://github.com/zed-industries/zed/pull/61199/changes/49acbf7c92414c14c453113eb9b886f9bedff7cb as there was no point in keeping a _"Show free models"_ toggle that would confuse users. Users that had `show_free_models` configures in Zed settings will get an `Property show_free_models is not allowed.` notice. Users that had any Custom OpenCode models with `"subscription": "free"` configured will get an `Value is not accepted. Valid values: "zen", "go".` notice. Neither are blocking errors. ## Testing ✅ Kimi K3 on OpenCode Go - happily confirmed Kimi K3 works by running a simple "_rename this variable for me. add a function. delete the function_" test. ✅ Grok 4.5 on OpenCode Go - bravely resisted the continuous and relentless waves of disgust and confirmed Grok 4.5 works by running a simple "_rename this variable for me. add a function. delete the function_" test. I was a bit surprised this worked as I was located in an EU country while testing this. ✅ Hy3 on OpenCode Go - happily confirmed Hy3 works by running a simple "_rename this variable for me. add a function. delete the function_" test. ✅ GPT 5.6 Luna on OpeCode Go - confirmed GPT 5.6 Luna works on OpenCode Go by running a simple "_rename this variable for me. add a function. delete the function_" test. ✅ Qwen 3.8 Max on OpeCode Go - confirmed Qwen 3.8 Max works on OpenCode Go by running a simple "_rename this variable for me. add a function. delete the function_" test. ✅ GLM 5.3 on OpeCode Go - confirmed GLM 5.3 works on OpenCode Go by running a simple "_rename this variable for me. add a function. delete the function_" test. 🤷 I did not test the new OpenCode Zen models (Claude Opus 5, Gemini 3.5 Flash Lite, Gemini 3.6 Flash, Kimi K3, Grok 4.6, Gemini 3.7 Flash, and Muse Spark 1.2) as I don't have a Zen subscription and I am stubbornly refusing to get one. ✅ Confirmed removal of OpenCode Free does not impact the rest of the OpenCode. Confirmed that any Free-related settings generate notices and not errors. Confirmed the OpenCode tab in Setting looks good. ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase <details> <summary>Screenshots of the OpenCode Free deprecation warnings</summary> **Notice shown in the corner of Zed**: <img width="345" height="90" alt="Notice banner shown in Zed" src="https://github.com/user-attachments/assets/3e65ba96-582c-424e-9335-1b43d6c632a8" /> **Notice shown in Settings -> LLM Providers -> OpenCode**: <img width="421" height="323" alt="Settings screen showing unexpected values" src="https://github.com/user-attachments/assets/a5eb6005-8576-4311-8b23-9c5baf314d8d" /> **Notice shown in `settings.json`**: <img width="569" height="231" alt="Notices shown in settings.json" src="https://github.com/user-attachments/assets/475375a1-268c-4420-8ef7-a896548e4498" /> </details> --- Release Notes: - Removed OpenCode Free models from Zed's built-in OpenCode provider because they are only available through OpenCode surfaces, such as its external agent through ACP. - Added Kimi K3, Grok 4.5, Hy3, GPT 5.6 Luna, Qwen 3.8 Max, and GLM 5.3 to OpenCode Go. - Added Claude Opus 5, Gemini 3.5 Flash Lite, Gemini 3.6 Flash, Gemini 3.7 Flash, Kimi K3, Grok 4.6, and Muse Spark 1.2 to OpenCode Zen. - Removed the deprecated Claude Opus 4.1 model from OpenCode Zen. ---- > [!TIP] > This pull request is **best reviewed commit-by-commit**! --------- Co-authored-by: dino <dinojoaocosta@gmail.com> |
||
|
|
c28cf645f9 |
Add explicit OpenAI conversation compaction and fix Anthropic compaction (#61370)
# Objective Add explicit conversation compaction for OpenAI Responses API models, available through both direct OpenAI connections and Zed Cloud models. Keep finalized replacement context provider-neutral and separate from the lifecycle events emitted while automatic compaction is in progress. ## Solution - Add opt-in explicit compaction support to the `LanguageModel` trait. - Separate streamed `CompactionUpdate` lifecycle events from finalized `CompactedContext`. - Represent provider-native compacted context as an opaque, versioned state owned by the originating provider. - Construct compact requests through the same OpenAI request conversion used for completions, then narrow the request to fields supported by `/responses/compact`. - Preserve and validate the complete canonical replacement window returned by OpenAI. - Replay the replacement window before messages sent after compaction, without resending the superseded transcript. - Support explicit compaction through both the direct OpenAI provider and `CloudLanguageModel`. - Update automatic OpenAI and Anthropic compaction to use the same finalized context representation. - Reject empty, malformed, incorrectly versioned, and incorrectly owned provider state. The corresponding Cloud change adds the `/completions/compact` proxy route: https://github.com/zed-industries/cloud/pull/3099. The downstream Delta UI integration is https://github.com/zed-industries/delta/pull/1739. ## Testing - `cargo nextest run -p anthropic -p open_ai -p language_models_cloud` - `cargo check -p language_models --tests` - `cargo fmt --all --check` - `git diff --check` The focused tests cover request construction, canonical-window preservation and replay, direct and Cloud transports, automatic compaction lifecycle events, malformed provider state, provider ownership, format compatibility, and HTTP failure handling. ## 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: - Added: System messages are now sent through the `instructions` field in OpenAI Responses API requests. |
||
|
|
3e976e89bc |
language_model: Add OpenAI Responses API custom tool support (#60638)
# Objective
Allow zed's language model stack to express OpenAI Responses API custom
tools (freeform text-input tools with an optional lark/regex grammar),
so downstream consumers can offer tools like a freeform `apply_patch` to
GPT models.
## Solution
- `LanguageModelRequestTool` now carries a Function-vs-Custom input
variant; `LanguageModelCustomToolFormat` models text/grammar formats.
- `LanguageModelToolUse.input` becomes a typed
`LanguageModelToolUseInput::{Json, Text}`. Serialization is tagged so
persisted Text inputs round-trip losslessly; legacy plain JSON values
still deserialize as `Json`.
- `open_ai` gains the custom tool wire types (tool definition,
`custom_tool_call`/`custom_tool_call_output` input items with
string-or-content-part outputs, output item, and
`custom_tool_call_input` delta/done stream events). The Responses event
mapper accumulates raw text deltas into `ToolUse` events, and history
replay derives custom-vs-function tool results from the matching
`ToolUse` by id.
- All non-OpenAI providers and the Chat Completions path error
explicitly when a request contains custom tools — no silent drops or
empty-schema coercions.
Release Notes:
- N/A
|
||
|
|
452e1cb273 |
opencode: Model updates + fixes (#60526)
**TL;DR**: model updates + reasoning levels + fixes discovered when working on https://github.com/zed-industries/zed/pull/60373 # Objective Since the model auto-discovery PR was [cancelled](https://github.com/zed-industries/zed/pull/60373#issuecomment-4886521448), here is a manual model list update! I also copied the stand-alone bugfixes/enhancements from that PR. ## Solution A lot of manual work 😅 **OpenCode Zen**: - added Fable 5 and Sonnet 5 - added models that were previously only available on OpenCode Go: GLM 5.2, Kimi K2.7 Code, and Minimax M3 - added reasoning levels for all models. I started from the data on [`Models.dev`](https://models.dev) (the `/api.json` raw data), and then I matched that with what is shown in the OpenCode CLI and what I know to be true **OpenCode Go**: - added reasoning levels for GLM 5.2 **OpenCode in general**: - added `protocol` validation for the settings, by moving from a random `String` to an `enum`, for both nicer error messages (random strings or typos will get an error instead of using `openai_chat` by default) and to avoid issues like [folks saying non-existent protocols are a thing](https://github.com/zed-industries/zed/issues/56869#issuecomment-4550154554) - enabled parallel tool calls by default. As per [OpenCode developer on Discord](https://discord.com/channels/1391832426048651334/1471233160993050918/1472020924881702912), _"almost all models worth using support parallel tool calling natively"_. Manual tests confirmed all OpenCode Go models support this correctly (and was enabled by default on the OpenCode side for all but 1 model). I initially wanted to skip this from the release notes, but I added it so folks are aware of it in case any issues are caused by this being enabled for all models - allegedly fixed Google thinking since reasoning levels / thinking effort levels were added for Google models and an auto-checker LLM highlighted that was not properly configured - added support for the new-ish `supports_disabling_thinking` so thinking-only models don't get a no-impact toggle to disable thinking I have no idea if any of the Free models will disappear in 2 days or not, so I did not update those 🤷 (as per decision in https://github.com/zed-industries/zed/issues/56869#issuecomment-4466637648) ## Testing The Zen and Google changes were not tested as I don't have a Zen subscription and I stubbornly refuse to get one. The Free&Go changes were tested by running a "_rename this variable for me. add a function. delete the function_" test with a few different models. ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Agent: OpenCode settings now validate `protocol` values - Agent: OpenCode only shows the "Disable thinking" toggle if thinking can indeed be disabled/enabled - Agent: OpenCode models now enable parallel tool calls by default - Agent: Updated OpenCode Zen models (added Fable 5, Sonnet 5, GLM 5.2, Kimi K2.7 Code, and Minimax M3) - Agent: Added OpenCode Go GLM 5.2 reasoning effort levels - Agent: Added reasoning effort levels for all OpenCode Zen models - Agent: Fixed thinking for OpenCode Zen Google models |
||
|
|
4ff55d09e5 |
Refactor agent settings UI code (#60274)
This PR removes/simplifies some APIs that were leftover after moving the agent settings from the agent panel into the agent settings UI. Behavior/UI should be identical. - Removed `ConfigurationViewTargetAgent` since only a single variant was used - Removed `configuration_view` and `configuration_view_v2` and replaced it with `settings_view` - Removed all the custom configuration views that were replaced by the API key view abstraction - Removed `intitial_title` and `initial_description` and moved it to `ProviderSettingsView` Release Notes: - N/A |
||
|
|
40d20036af |
settings_ui: Remove feature flag for AI settings and adjust design (#59860)
Closes AI-159 Closes AI-434 Closes AI-435 Release Notes: - Key agent-related settings now live in the settings editor, close to all other settings available in Zed. This specifically includes the move of LLM providers, external agents, and MCP servers to the settings editor. --------- Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com> Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de> |
||
|
|
593ca12e3f |
ai: Add Max reasoning effort (#59806)
# Objective More and more models are supporting the `max` reasoning effort (DeepSeek V4, GLM 5.2, etc) and that was missing from Zed. ## Solution Added `ReasoningEffort::Max` level and implemented support for that across providers. For most providers this is a no-op as they don't support that (`max` is missing from `supported_reasoning_levels()`) but for some providers this required tiny changes: for OpenCode there is now a proper difference between `xhigh` and `max` (this bug was actually what triggered this whole PR) and for DeepSeek reasoning levels were migrated from a custom `deepseek::ReasoningEffort`. ## Testing Tested and confirmed working with a simple _"rename this variable for me. add a function. delete the function"_ test across a few providers (OpenCode, GitHub Copilot, and DeepSeek). ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase N/A --- Release Notes: - OpenAI-compatible: added support for `max` reasoning levels - OpenCode: added support for `max` reasoning levels |
||
|
|
7187d65774 |
language_models: Set support_thinking in Responses API for OpenAI-compatible provider (#59213)
# Objective Fix OpenAI-compatible reasoning/thinking support. Previously, `OpenAiCompatibleLanguageModel` never reported thinking support, so configured `reasoning_effort` values did not reliably reach the wire and Responses API reasoning state could miss `include: ["reasoning.encrypted_content"]`. Fixes #58289 Addresses #59207 for OpenAI-compatible Responses models configured with `reasoning_effort`. ## Solution - Treat a non-`none` configured `reasoning_effort` as OpenAI-compatible thinking support. - Expose common OpenAI-style effort levels in the agent UI, using the configured effort as the default. - Honor selected reasoning effort for OpenAI-compatible chat-completions requests. - Send `reasoning_effort: "none"` when thinking is disabled for a configured reasoning model. - Preserve native OpenAI behavior by continuing to use native model-specific supported efforts and `max_completion_tokens`. - Add an OpenAI-compatible `max_tokens_parameter` capability for endpoints that expect output limits as `max_tokens`. - Parse common streamed thinking fields (`reasoning` and `reasoning_content`). - Add provider setup UI and docs for configuring OpenAI-compatible reasoning models. ## Testing - `cargo fmt -p language_model_core -p agent_ui -p language_models` - `cargo test -p language_models provider::open_ai_compatible::tests --lib` - `cargo test -p language_models provider::open_ai::tests --lib` - `cargo test -p open_ai completion::tests --lib` - `cargo test -p agent_ui agent_configuration::add_llm_provider_modal::tests --lib` - `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: - Improved OpenAI-compatible provider setup for reasoning models. --------- Co-authored-by: Anant Goel <anant@zed.dev> |
||
|
|
fef979dec4 |
language_models: Add Anthropic-compatible provider support in settings (#50381)
Release Notes: - Added Anthropic-compatible provider support in settings 1. add anthropic-compatible provider via menu https://github.com/user-attachments/assets/14b33d59-ae08-4215-b05f-9f3896a4a6f2 2. use anthropic-compatible https://github.com/user-attachments/assets/8bc7f1c5-644e-4528-942e-29150c35fed0 --------- Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com> Co-authored-by: Anant Goel <anant@zed.dev> Co-authored-by: Jakub Konka <kubkon@jakubkonka.com> |
||
|
|
bb5951b7ca |
language_models: Support custom HTTP headers for provider requests (#55246)
Add a `custom_headers` setting to each HTTP-based language model provider (Anthropic, Bedrock, DeepSeek, Google, LM Studio, Mistral, Ollama, OpenAI, OpenAI-compatible, OpenCode, OpenRouter, Vercel AI Gateway, and xAI) so users can attach extra headers to every outgoing request. Headers managed by Zed (authentication, content-type, etc.) cannot be overridden and are skipped with a warning. 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) - [] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Added support for configuring custom HTTP headers on language model providers via `language_models.<provider>.custom_headers`. Signed-off-by: Aurabindo Pillai <mail@aurabindo.in> |
||
|
|
a6b0ee9f36 |
Add Claude Opus 4.8 support (#57984)
<img width="627" height="752" alt="Screenshot 2026-05-28 at 1 20 22 PM" src="https://github.com/user-attachments/assets/0a7825f0-73c5-49e9-b59a-83924a45de98" /> Adds Claude Opus 4.8 for BYOK providers, including Anthropic fast-mode handling and Bedrock/OpenCode model definitions. Closes AI-336 Release Notes: - Added Claude Opus 4.8 BYOK support |
||
|
|
7dcd422a73 |
opencode: Model updates (#57076)
**TL;DR**: clearer docs + models cleanup. ---- **Docs**: - as per the discussion in https://github.com/zed-industries/zed/issues/56869, added a note to the docs highlighting that temporary models should be configured using Custom Models. Adding a whole example felt redundant considering the full example is literally 2 rows below. **Model updates**: - **Ring 2.6 1T Free**: removed - **GLM 5 and GLM 5.1**: different settings based on subscription — [131k](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode/models/glm-5.1.toml#L22) [output](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode/models/glm-5.toml#L22) on OpenCode but [32k](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode-go/models/glm-5.1.toml#L22) [output](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode-go/models/glm-5.toml#L22) on OpenCode Go - **MiniMax M2.5**: different settings based on subscription — [131k output on OpenCode](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode/models/minimax-m2.5.toml#L22) and [65k on OpenCode Go](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode-go/models/minimax-m2.5.toml#L19) - **Nemotron 3 Super Free**: enabled interleaved reasoning as per [docs](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode/models/nemotron-3-super-free.toml#L13). Ran some quick tests and confirmed everything seems to work fine (_"rename this variable. add a simple function. remove the function. tell me a joke"_) - **GPT 5.3 Codex Spark**: removed image support as per [docs](https://github.com/anomalyco/models.dev/blob/dev/providers/opencode/models/gpt-5.3-codex-spark.toml#L23-L25) The [docs say GLM 5 in OpenCode Zen has a deprecation date of May 14](https://opencode.ai/docs/zen/#deprecated-models) but that seems to still be active and is [not marked as deprecated on models.dev](https://github.com/anomalyco/models.dev/blob/8e710e19eabbfa464764afe54d67585cbee9f4d8/providers/opencode/models/glm-5.toml) so I didn't remove it yet 🤷 ---- 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes https://github.com/zed-industries/zed/issues/56869 Release Notes: - OpenCode: updated models (removed Ring 2.6 1T Free, enabled interleaved reasoning for Nemotron 3 Super Free, deleted incorrect image support for GPT 5.3 Codex Spark, and updated token counts for MiniMax M2.5, GLM 5, and GLM 5.1) - OpenCode Free: clearer docs for temporary free models |
||
|
|
37f6d7a15c |
Add ChatGPT subscription provider via OAuth 2.0 PKCE (#53166)
Adds a new language model provider that lets users authenticate with their ChatGPT Plus/Pro subscription and use OpenAI models (codex-mini-latest, o4-mini, o3) directly in the Zed agent — without needing a separate API key. ## How it works 1. **OAuth 2.0 + PKCE sign-in**: Uses OpenAI's official Codex CLI client ID to run an authorization code flow. A local HTTP server on `127.0.0.1:1455` captures the callback, exchanges the code for tokens, and stores them in the system keychain. 2. **Token refresh**: Access tokens are automatically refreshed when they're within 5 minutes of expiry, using the stored refresh token. 3. **Responses API**: Requests go to `https://chatgpt.com/backend-api/codex/responses` using the existing `open_ai::responses` client (Responses API format, not Chat Completions which was deprecated for this endpoint in Feb 2026). 4. **Required headers**: `originator: zed`, `OpenAI-Beta: responses=experimental`, `ChatGPT-Account-Id` (extracted from JWT), `store: false` in the body. ## Files changed - `crates/open_ai/src/responses.rs`: Add `store: Option<bool>` field to `Request`; add `extra_headers` param to `stream_response` for per-provider header injection - `crates/language_models/src/provider/openai_subscribed.rs`: New provider (sign-in UI, OAuth flow, token storage/refresh, model list) - `crates/language_models/src/provider/open_ai.rs`, `open_ai_compatible.rs`, `opencode.rs`: Pass `vec![]` for new `extra_headers` param - `crates/language_models/src/language_models.rs`: Register the new provider - `crates/language_models/Cargo.toml`: Add `rand` and `sha2` deps for PKCE ## Open questions / known gaps - [ ] **Terms of service**: Usage appears to be within OpenAI's ToS (interactive use via their official CLI client ID), but needs legal sign-off before shipping - [ ] **Redirect URI**: Currently `http://localhost:1455/auth/callback` — may need to match exactly what OpenAI's Codex CLI uses - [ ] **UI polish**: The sign-in card is functional but minimal; needs design review - [ ] **Error messages**: OAuth error responses from the callback URL aren't surfaced to the user yet - [ ] **`o3` availability**: o3 may require a higher subscription tier; consider gating it ## Testing Sign-in flow was designed to match the Copilot Chat provider pattern. Manual testing against the live OAuth endpoint is needed. Release Notes: - Added ChatGPT subscription provider, allowing users to use their ChatGPT Plus/Pro subscription with the Zed agent --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> Co-authored-by: Richard Feldman <richard@zed.dev> Co-authored-by: Richard Feldman <oss@rtfeldman.com> Co-authored-by: Agus Zubiaga <agus@zed.dev> |
||
|
|
956dbea79a |
copilot: Fix cache control error (#56632)
#56472 broke Copilot chat > Failed to connect to API: 400 Bad Request {"message":"cache_control: Extra inputs are not permitted"} This PR makes it so that we still use the legacy caching approach for Copilot Release Notes: - N/A |
||
|
|
78c889c21d |
open_ai: Responses API improvements (#56476)
Release Notes: - Removed deprecated OpenAI models - Added support for gpt-5.4-nano/mini models for OpenAI provider - Improved output quality when using OpenAI models --------- Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de> Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Gaauwe Rombouts <mail@grombouts.nl> |
||
|
|
be705e677b |
Merge gpui::Task and scheduler::Task (#53674)
Release Notes: - N/A or Added/Fixed/Improved ... |
||
|
|
a42374250f |
opencode: Support interleaved_reasoning and fix DeepSeek (#55574)
OpenCode API endpoints for DeepSeek were [moved from Anthropic-compatible to OpenAI-compatible](https://github.com/anomalyco/opencode/pull/24500) and DeepSeek requires interleaved reasoning enabled to work. I ran a _"rename this variable to potato"_ test and I can confirm DeepSeek V4 Flash and Pro both work now 🎉 Some other OpenCode Go models were marked [on models.dev](https://github.com/anomalyco/models.dev/tree/dev/providers/opencode-go/models) as supporting `interleaved_reasoning` so they too got that enabled. Kimi K2.5 and Kimi K2.6 continue to fail with https://github.com/zed-industries/zed/issues/51743 (https://github.com/zed-industries/zed/pull/55085 seems to hint at this being [an OpenCode issue](https://github.com/zed-industries/zed/issues/51743#issuecomment-4336785765)?), but all other models seem to work fine both with `interleaved_reasoning` and without it 🤷 I assume it's better to have that turned on? Again, the intersection of OpenAI Chat Completions API, different models, different inference providers, how they all work together is something I know nothing about! 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) - [ ] Tests cover the new/changed behavior - [X] Performance impact has been considered and is acceptable Release Notes: - OpenCode Go: use correct DeepSeek endpoints - OpenCode: add support for interleaved_reasoning |
||
|
|
5eec0cecc1 |
opencode: Model updates + thinking levels (#54880)
Leftovers after https://github.com/zed-industries/zed/pull/53651 Updated models: - **Zen**: GPT 5.5 and GPT 5.5 Pro - not tested because I don't have a Zen subscription and I stubbornly refuse to get one - **Go**: DeepSeek V4 Pro and DeepSeek V4 Flash - failing due to https://github.com/anomalyco/opencode/issues/24224 - **Go**: MiMo V2.5 and MiMo V2.5 Pro - tested, confirmed working - **Free**: Ling 2.6 Flash, [available for "a limited time"](https://x.com/opencode/status/2046717718028513694) - tested, confirmed working - **Free**: Hy3 Preview, [available until May 8](https://x.com/opencode/status/2047328981435756824) - tested, confirmed working When testing the new models and comparing with OpenCode CLI, I realized the [variants](https://opencode.ai/docs/models/#built-in-variants)/thinking effort configuration was not supported by the Zed Agent implementation. I added that for OpenCode Go models, after manually checking what each model supports in OpenCode. Reasoning levels and everything seems to work (UI looks good, model works) but I have no idea how to specifically test reasoning levels without doing a full benchmark 🤷 I did not add the same thing for OpenCode Zen models because I could not figure out a way to get the supported variants. @benbrandt let me know if you want me to take this out of this PR and to keep just the model updates! 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - OpenCode: add new models (GPT 5.5, DeepSeek V4, MiMo V2.5, Ling 2.6, Hy3) - OpenCode Go: add support for configurable reasoning effort levels --------- Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> |
||
|
|
f59c122bee |
opencode: Add support for OpenCode Go (#53651)
**TL;DR**: add support for OpenCode Go (flat-rate monthly subscription) along the already-implemented OpenCode Zed (pay-as-you-go billing). > [!WARNING] > This code was written by LLMs, under the supervision of a so-called developer that never wrote Rust profesionally and that spends more time in Pages&Keynote than in an IDE. 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Background OpenCode offers a few different ways to access models: - **free access to 3 models**, with feedback and data used to improve the model. These models use the OpenCode Zen API endpoints, but have different usage limits (200 requests per 5 hours) and have a different privacy policy. Some people disable or block the free models, some people are super-excited to have access to LLMs for free, and some people like using the free models to test new LLMs (at launch MiMo-V2 had 2 free weeks of usage, for example). - **pay-as-you-go access to 30 models** as part of the [OpenCode Zen](https://opencode.ai/zen) subscription. These models use the same OpenCode Zen API endpoints. - **flat-rate monthly access to 7 models** as part of the [OpenCode Go](https://opencode.ai/go) subscription. These models use the OpenCode Zen API endpoints with an extra `/go` appended to the path. There are 5-hour, weekly, and monthly usage limits and, additionally, users can toggle a switch in the OpenCode Console to use Zen models with their pay-as-you-go billing after the Go limits are hit. There's also a currently-paused [OpenCode Black](https://opencode.ai/black) flat-rate subscription with way higher usage limits and with access to more models, with $100 and $200 monthly plans. The whole thing is a bit messy, but it's great value and highly reliable LLM access! <br> https://github.com/zed-industries/zed/pull/49589 added support for OpenCode Zen by implementing a new `opencode` provider. OpenCode Go [could be used by overriding the API URL](https://github.com/zed-industries/zed/pull/49589#issuecomment-4130300454), but that is a terrible user experience: some models have to be manually added, the model list always shows the 30-something OpenCode Zen models, and free models cannot be used at all. I was annoyed by the experience of using OpenCode Go with Zed and this past week I had to test a bunch of LLMs and providers and harnesses, so I took this on as a test case 🙂 ## Implementation This PR makes the OpenCode provider more general (not just for Zen) and adds an `OpenCodeModelSubscription` concept which is then used to implement support for OpenCode Go. The free models are also broken out into their own subscription for a prettier model list. For a better user experience, the different subscriptions can be enabled or disabled, both in the settings file and in the UX: <img width="434" height="176" alt="Screenshot showing the OpenCode provider configuration, with the newly added toggles" src="https://github.com/user-attachments/assets/3520e114-00c8-4794-84bf-35cd72d9c57e" /> The code was written by LLMs, but I do understand it and I did a bunch of "manual" iterations and "manual" tweaks. Still, my Rust experience is non-existent so **I won't feel offended if y'all reject this PR**! I did consider alternatives (adding a new `opencode-go` provider and renaming this to `opencode-zen`, for example, or adding support for custom API URLs in OpenCode custom models which would've been the smallest code change but a terrible user experience, and so on) but all alternatives would have been, in my opinion, a worse user experience. **Tests I did**: - confirmed OpenCode Go models work as expected - confirmed OpenCode Zen Free models work as expected - confirmed I get an error when trying to use OpenCode Zen models since I don't have that subscription - confirmed the subcription toggles work as expected (model are shown/hidden, settings file is updated) **Notes**: - this PR is best reviewed commit-by-commit. I did not create a separate PR for the model updates to minimize delays - my exeprience with Rust is roughly zero, but I tried to strike a balance between idiomatic Rust and easy-to-read code - users of the OpenCode provider might have to do some re-configuration after this PR is merged since the model identifiers now include the subscription, eg `claude-haiku-4-5` is now `zen/claude-haiku-4-5`. Since this is a relatively new provider and the impact is small, I preffered that rather than adding complex migration/mapping logic. - does changing the provider name from "OpenCode Zen" to "OpenCode" break anything for y'all at Zed? - does changing the telemetry id from `"opencode/<model-id>"` to `"opencode/<subscription>/<model-id>"` break anything for y'all at Zed? --- Release Notes: - OpenCode provider: add support for OpenCode Go --------- Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> |
||
|
|
2eafa6e6aa |
language_models: Remove unused language model token counting (#54177)
Drop the `count_tokens` API and related implementations across providers, and remove the unused `tiktoken-rs` dependency. I was going to update the dependency becuase they finally released a fix we needed. But then I realized we only used this api in one place, the Rules library. And for most models it would have been wildly incorrect becuase we use tiktoken, i.e. OpenAI tokenizers, for almost every model, which is going to give incorrect results. Given that, I just removed these because the difference in how we get these has caused plenty of confusion in the past. 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 |
||
|
|
7b082cbb6f |
Add interleaved_reasoning option to openai compatible models (#54016)
Release Notes: - Added interleaved_reasoning option to openai compatible models --- This PR adds the interleaved_reasoning option for OpenAI-compatible models, addressing the issue described in https://github.com/ggml-org/llama.cpp/issues/20837. In my testing, enabling interleaved_reasoning not only resolved the tool-calling issues encountered by Qwen3.5 models in llama.cpp, but also appeared to improve the model's coding capabilities. I have also verified the outgoing requests using a proxy to ensure the parameter is being sent correctly.It is also likely that this change will benefit other models and providers as well. Note: While I used AI to assist with the implementation, I have reviewed and tested the changes. As I am relatively new to Rust and the Zed codebase, I would appreciate any feedback or suggestions for improvement. I am happy to make further adjustments if needed. Thank you all for building such an amazing editor! Co-authored-by: Oleksiy Syvokon <oleksiy@zed.dev> |
||
|
|
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 |
||
|
|
adb3533890 |
agent: Add Opencode Zen provider (#49589)
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) Per Opencode's website: > Zen gives you access to a curated set of AI models that OpenCode has tested and benchmarked specifically for coding agents. No need to worry about inconsistent performance and quality, use validated models that work. > - [x] Testing select models and consulting their teams > - [x] Working with providers to ensure they're delivered properly > - [x] Benchmarking all model-provider combinations we recommend There are so many models available, but only a few work well with coding agents. Most providers configure them differently with varying results. The models under the Zen umbrella typically have a more reliable token(s) per second speed with minimal outages. The opencode ecosystem has improved my workflow if not many others' ! Release Notes: - Added [Opencode Zen](https://opencode.ai/zen) to list of providers --------- Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de> |