anthropics / anthropics/claude-code

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

Đang mở
#89,211 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area:providers area:tools bug has repro platform:windows
Ngôn ngữ chính
Python
Star
145k
Fork
23.1k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api, cli
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.