[Bug] Anthropic models: tool calls fail with "Input tag 'input_json_delta' ... does not match any of the expected tags" (streamed tool_use never assembled)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- ai, backend-api-design
Hướng nghiên cứu
Bắt đầu tại apps/application/flow/tools.py, ở _yield_mcp_response(), sau đó tìm trong toàn bộ cây mã nguồn input_json_delta và partial_json như mô tả. Tái hiện một lệnh gọi tool Anthropic được stream và so sánh với provider có dạng OpenAI đang hoạt động; hoàn tất khi giá trị của tool đi tới câu trả lời mà không xảy ra Anthropic BadRequestError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
MaxKB Version
v2.10.4-lts (also reproduced on v2.10.2-lts)
Problem Description
When an application has a custom tool attached and uses an Anthropic model (model_anthropic_provider), every message that triggers a tool call fails. The Anthropic API rejects MaxKB's follow-up request:
BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error',
'message': "messages.1.content.1: Input tag 'input_json_delta' found using 'type' does not match any of the expected tags"}}
and, in the other variant:
BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error',
'message': 'messages: text content blocks must be non-empty'}}
MaxKB returns this to the caller as HTTP 200 with the error text as the answer body, so it reaches end users as the assistant's reply.
Cause
input_json_delta is an Anthropic streaming event type, not a message content type. Anthropic streams tool arguments as a series of content_block_delta events of type input_json_delta, each carrying a partial_json fragment. These must be accumulated and assembled into a completed tool_use content block before the assistant turn is replayed in messages.
MaxKB appears to replay the raw streamed deltas instead. A search of the v2.10.4-lts tree finds no handling for either field:
grep -rn "input_json_delta\|partial_json" apps/ # zero hits
_yield_mcp_response() in apps/application/flow/tools.py handles only OpenAI-shaped tool deltas (tool_call_chunks / tool_calls / invalid_tool_calls). There is no branch for Anthropic content blocks, which is consistent with both error messages: the unassembled delta is sent verbatim, and the accompanying text block is empty.
Steps to Reproduce
- Register an Anthropic model (reproduced with
claude-sonnet-5,model_anthropic_provider). - Create a SIMPLE agent using that model.
- Create a custom Python tool and attach it (
tool_enable: true), e.g.
def live_price(query):
return 'DJI Neo: 4242.42 GEL, in stock.'
- Set the system prompt so the tool is actually used, e.g. "For any question about price or stock you MUST call the live_price tool."
- Call the OpenAI-compatible endpoint with
stream: true(required — with tools attached,stream: falseis unsupported per #6300 / #4846 / #4363):
curl -N "$MAXKB/chat/api/$APP_ID/chat/completions" \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"model":"gpt-3.5-turbo","stream":true,"messages":[{"role":"user","content":"How much is the DJI Neo?"}]}'
Expected: the answer quotes the tool's value (4242.42 GEL).
Actual: the answer is the BadRequestError text above.
The same setup works on an OpenAI-shaped provider
Identical agent, identical tool, identical prompt, only the model swapped to model_openai_provider (gpt-4o-mini): no error, and the answer contains 4242.42 GEL, confirming the tool executed. This isolates the defect to the Anthropic provider's streamed tool-call handling rather than to tools, sandboxing, or the endpoint.
Impact
Custom tools and MCP cannot be used at all with Anthropic models. Because tools require stream: true, and streaming is exactly where the assembly fails, there is no working combination for Anthropic users.
Tested on v2.10.2-lts and v2.10.4-lts (CE), Docker, single-node.
- Ngôn ngữ chính
- Python
- Star
- 22.8k
- Fork
- 3.2k
- Merge trung bình
- 1 giờ 19 phút
- Pull request đã merge (30 ngày)
- 286
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của 1Panel-dev/MaxKB
-
[Bug] 使用多个MCP时,只会选择一个MCP服务 Đang mởStatus: Awaiting Feedback
1Panel-dev/MaxKB#7120 · 2 bình luận · 1 người được giao ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
1Panel-dev/MaxKB#7081 · 1 bình luận ·
-
Status: Awaiting Feedback
1Panel-dev/MaxKB#7069 · 8 bình luận · 1 người được giao ·
-
1Panel-dev/MaxKB#7067 · 1 người được giao ·
-
Type: Bug
1Panel-dev/MaxKB#7062 · 2 bình luận · 1 người được giao ·
Tất cả issue của 1Panel-dev/MaxKB
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
zilliztech/memsearch#759 ·