# copilot_chat: Serialize ToolChoice::Any as "required" instead of "any" \(\#52015\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/b0f286042b6e325c3761bb8d72a7f8c4bb8573d8)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: b0f286042b6e325c3761bb8d72a7f8c4bb8573d8

Requested commit: b0f286042b6e325c3761bb8d72a7f8c4bb8573d8

Commit: b0f286042b6e325c3761bb8d72a7f8c4bb8573d8

Tree: e0e13132725e220a714c544f79cdd14c86b769fa

Author: Valery Borovsky

Committer: GitHub

## Message

```
copilot_chat: Serialize ToolChoice::Any as "required" instead of "any" (#52015)

**Observed behavior:** Inline assistant failed for GPT-4.1,
Gemini, and other non-Anthropic models. Claude worked correctly because
Anthropic's API accepts `"any"` as a valid value.

## Fix
Renamed `ToolChoice::Any` → `ToolChoice::Required` in both
`copilot_chat.rs` and `responses.rs`, matching the convention used by
other OpenAI-compatible providers (`open_ai`, `lmstudio`,
`open_router`).

`copilot_chat::ToolChoice` is a wire type only for the
`/chat/completions`
path — Anthropic models go through `into_anthropic()` and never touch
it,
so no per-model logic is needed.

Also fixes the same serialization bug in `responses::ToolChoice`, which
was not covered by the original approach, and adds regression tests for
both.

## Affected models
- `gpt-4.1` via copilot_chat provider
- `gemini-*` via copilot_chat provider
- Likely affects all OpenAI-compatible models routed through
copilot_chat

## Screenshots
**Bug (only Claude works, Gemini and GPT-4.1 fail):**
<img width="598" height="209" alt="image"
src="https://github.com/user-attachments/assets/bbd418d9-7de3-4191-9ca9-fd1961534e23"
/>

**Fix:**
<img width="532" height="154" alt="image"
src="https://github.com/user-attachments/assets/86bb0f8e-67e6-4417-9b78-b1b7ad328e9e"
/>

**Result:** After the fix, all models work correctly via inline
assistant.

## Release Notes
- Fix inline assistant 400 errors for GPT-4.1, Gemini, and other
  non-Anthropic models via the copilot_chat provider (`tool_choice` was
  sending `"any"` instead of `"required"`)
```

## Parents

- [4b60e639bc0c75c79f3b82134ae44a67ddd351a7](https://git.cafe/gitcafe/zed/commit/4b60e639bc0c75c79f3b82134ae44a67ddd351a7?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/b0f286042b6e325c3761bb8d72a7f8c4bb8573d8?format=markdown)
