anthropics / anthropics/claude-code

[BUG] Deferred custom tools break non-Anthropic models behind custom ANTHROPIC_BASE_URL

Aperta
#89,211 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area:providers area:tools bug has repro platform:windows
Lingua principale
Python
Stelle
145k
Fork
23.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

## Summary

Claude Code enables deferred tool loading / ToolSearch when used through a custom `ANTHROPIC_BASE_URL`.

When the backend serves a non-Anthropic model that supports normal tool calling but does not implement Anthropic's deferred custom tool protocol, Claude Code can fail with:

```text
API Error: 400 Deferred custom tools are only supported on Anthropic models and on Anthropic-compatible
provider endpoints that implement deferral. Other endpoints cannot call tools omitted from tools[].
Received stealth/ox-alpha.
```

In some agentic tasks, the symptom can also look less obvious: Claude Code works for several seconds, returns to the prompt before the task is finished, and the user has to repeatedly type `continue`.

## Environment

* Claude Code: `2.1.241`
* Platform: `win32-x64`
* Installation: npm global
* Custom endpoint configured through `ANTHROPIC_BASE_URL`
* Model: `stealth/ox-alpha`
* Operating system: Windows
* Claude Code doctor reports:

```text
ANTHROPIC_BASE_URL is set and does not point at api.anthropic.com
```

## Reproduction

1. Configure Claude Code to use a custom Anthropic-compatible endpoint via `ANTHROPIC_BASE_URL`.
2. Use a non-Anthropic model supporting standard tool calling, e.g. `stealth/ox-alpha`.
3. Start Claude Code normally.
4. Send a prompt that causes Claude Code to use a deferred tool.
5. Claude Code returns:

```text
API Error: 400 Deferred custom tools are only supported on Anthropic models and on Anthropic-compatible
provider endpoints that implement deferral. Other endpoints cannot call tools omitted from tools[].
Received stealth/ox-alpha.
```

## Root Cause

Claude Code can use ToolSearch/deferred tool loading, meaning some tool definitions are omitted from the initial `tools[]` request and loaded later.

This requires support for Anthropic's deferred tool semantics.

A backend/model may support ordinary Anthropic-style tool calling while not supporting deferred custom tools. In that case, Claude Code's deferred tool mode is incompatible with the endpoint.

## Workaround

Disable ToolSearch / deferred loading:

### PowerShell

```powershell
$env:ENABLE_TOOL_SEARCH="false"
claude
```

Or configure it persistently in Claude Code settings:

```json
{
"env": {
"ENABLE_TOOL_SEARCH": "false"
}
}
```

With ToolSearch disabled, tools are provided normally instead of relying on deferred loading.

## Expected Behavior

For a custom `ANTHROPIC_BASE_URL`, Claude Code should either:

1. detect whether the provider supports deferred custom tools before enabling ToolSearch; or
2. automatically fall back to standard/eager tool loading if deferred tools are unsupported; or
3. provide a clear startup warning explaining that `ENABLE_TOOL_SEARCH=false` is required.

Ideally, users should not encounter this only after an agent attempts to invoke a deferred tool.

## Additional Context

This is especially confusing because the endpoint/model may otherwise support normal tool calling correctly. The failure is specifically related to deferred tool definitions rather than tool calling in general.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start by reproducing the failure with a custom ANTHROPIC_BASE_URL, a non-Anthropic tool-calling model, and deferred loading enabled; compare it with ENABLE_TOOL_SEARCH=false. Trace where Claude Code enables ToolSearch for custom endpoints, then verify that unsupported deferred tools are detected, eager loading is used, or a clear warning is shown before tool invocation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api, cli
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.