anthropics / anthropics/claude-code

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

Abierto
#89,211 0 comentarios 0 reacciones 0 asignados Ver en GitHub
area:providers area:tools bug has repro platform:windows
Lenguaje dominante
Python
Estrellas
145k
Forks
23.1k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
api, cli
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.