zed/crates/language_model_core
zerx-lab d0a977e651
Allow configuring adaptive thinking for Anthropic available_models (#57207)
Split off from #57105 per @maxdeviant's review.

`language_model_core::ModelMode` previously had only `Default` and
`Thinking` variants. As a result, `available_model_to_anthropic_model`
in the Anthropic provider had a dead branch for `AdaptiveThinking` that
was never reachable from settings, and users manually configuring Claude
models via `available_models` could only toggle extended thinking on/off
— they could not opt into adaptive thinking and its
low/medium/high/xhigh/max effort selector. This matters most for users
on third-party Anthropic-compatible proxies, where the `/v1/models`
endpoint may not report a `capabilities` block, leaving
`available_models` as the only path to enable adaptive thinking.

Add an `Adaptive` variant to `ModelMode` and map it to
`AnthropicModelMode::AdaptiveThinking` in the Anthropic provider's
settings conversion. Users can now write:

```json
{
  "language_models": {
    "anthropic": {
      "available_models": [
        {
          "name": "claude-opus-4-7",
          "display_name": "Claude Opus 4.7",
          "max_tokens": 1000000,
          "max_output_tokens": 128000,
          "mode": { "type": "adaptive" }
        }
      ]
    }
  }
}
```

and get the full adaptive-thinking UX in the agent panel.

### Impact on other providers

`ModelMode` is re-exported by Google (`GoogleModelMode`) and OpenRouter.
Both already use non-exhaustive `matches!` checks for `Thinking`, so the
new variant naturally falls through to "no thinking" without compile
breakage. Bedrock defines its own local `ModelMode` enum and is
unaffected. `cargo check --workspace --all-targets` passes.

### Tests

Three new tests in `crates/language_models/src/provider/anthropic.rs`
covering Adaptive / Thinking / Default settings → model mapping:

- `cargo test -p language_models --lib provider::anthropic::`: 3/3
passing.
- `./script/clippy --package language_models --package
language_model_core`: clean.

Release Notes:

- agent: Added support for `"mode": { "type": "adaptive" }` for custom
anthropic to enable adaptive thinking

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
2026-07-14 15:04:47 +00:00
..
src Allow configuring adaptive thinking for Anthropic available_models (#57207) 2026-07-14 15:04:47 +00:00
Cargo.toml Fix MCP tools with $ref/$defs being silently rejected (#60165) 2026-07-07 07:56:02 +00:00
LICENSE-GPL