anthropics / anthropics/claude-code

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

Offen
#89,211 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:providers area:tools bug has repro platform:windows
Vorherrschende Sprache
Python
Sterne
145k
Forks
23.1k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

## 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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api, cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.