fix(ai-anthropic): chat({ reasoning }) on Claude 4.6 sends a top-level effort and gets a 400
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #1737 của @tombeckenham — đã merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 20/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ệ
- typescript
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Read packages/ai-anthropic/src/text/reasoning.ts, then inspect the request assertions in packages/ai-anthropic/tests/reasoning-request.test.ts and the Anthropic adapter note in docs/adapters/anthropic.md. Update the Claude 4.6 effort shape, its test, and the documentation as described; done means the tests expect output_config.effort and the docs match. The reporter says they are also opening a PR, so check that work before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
TanStack AI version
main at 7532b2b09 (@tanstack/ai 0.68.0, unreleased). The bug came in with #1692 and is not on npm yet. Release PR #1699 is still open.
Framework/Library version
None. This is in @tanstack/ai-anthropic, on the server.
Describe the bug and the steps to reproduce it
chat({ reasoning }) on claude-opus-4-6 or claude-sonnet-4-6 sends the effort as a top-level effort field. Anthropic rejects it with a 400. Both models accept output_config.effort, the same shape the adapter already sends for Claude 4.7 and later.
Every level other than off fails. A call that sets budgetTokens is not affected, because it takes the budget path and sends no effort.
import { chat } from '@tanstack/ai'
import { anthropicText } from '@tanstack/ai-anthropic'
chat({
adapter: anthropicText('claude-sonnet-4-6'),
messages: [{ role: 'user', content: 'Say hi' }],
reasoning: 'low',
})
// 400 invalid_request_error: "effort: Extra inputs are not permitted"
Live results from the Messages API on 2026-10-13, with thinking: { type: 'adaptive', display: 'summarized' }:
| Model | Shape | Result |
|---|---|---|
claude-sonnet-4-6 |
top-level effort: "low" |
400 effort: Extra inputs are not permitted |
claude-sonnet-4-6 |
output_config: { effort: "low" } |
200 |
claude-opus-4-6 |
top-level effort: "low" |
400, same message |
claude-opus-4-6 |
output_config: { effort: "low" } |
200 |
claude-sonnet-4-6 on /v1/messages?beta=true |
top-level effort: "low" |
400, same message |
The adapter sends every call through client.beta.messages, so the last row is the path it uses. That request had no betas header.
Where it is:
packages/ai-anthropic/src/text/reasoning.ts:17definesTOP_LEVEL_EFFORTfor the two 4.6 models. Line 76 returns{ thinking, effort }for them.packages/ai-anthropic/tests/reasoning-request.test.ts:91pins the wrong shape ("Claude 4.6: the effort is a top-level field").docs/adapters/anthropic.md:321says "Claude 4.6 gets adaptive thinking and the top-leveleffort".
Suggested fix: delete TOP_LEVEL_EFFORT and always return output_config: { effort }. Drop the effort? field from AnthropicThinkingFields. Flip the test and fix the docs line.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":2000,"thinking":{"type":"adaptive","display":"summarized"},"effort":"low","messages":[{"role":"user","content":"Say hi"}]}'
Swap "effort":"low" for "output_config":{"effort":"low"} and the same request returns 200.
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.2k
- Fork
- 365
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 242
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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 TanStack/ai
-
withPersistence does not save activity rows when a run is stopped or failsCó thể đã có người làm @tombeckenham đã nhận 4 ngày trước. Đang mởwaiting-on: maintainer
TanStack/ai#1804 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Activity events that a chat middleware emits are streamed but never recorded or persistedCó thể đã có người làm @AlemTuzlak đã nhận 4 ngày trước. Đang mởwaiting-on: maintainer
TanStack/ai#1803 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
withPersistence stores the durability batch hint on a stopped or failed assistant messageCó thể đã có người làm @tombeckenham đã nhận 4 ngày trước. Đang mởhas-pr waiting-on: maintainer
TanStack/ai#1802 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Discriminate status-dependent record and option types (RunRecord, SessionIndexEntry, InputState, durable-only options)Có thể đã có người làm @jherr đã nhận 4 ngày trước. Đang mởenhancement waiting-on: maintainer
TanStack/ai#1799 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-harness: an input with no principal runs with the owner session's principalCó thể đã có người làm @tombeckenham đã nhận 5 ngày trước. Đang mởwaiting-on: maintainer
TanStack/ai#1797 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Edit: Travel Mix (RO)Đang mởcheck:failed streams:edit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
iptv-org/iptv#55901 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
package:ios ships XCFrameworks with absolute symlinks, which SwiftPM refuses to extractCó thể đã có người làm @cusnirvladislav đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
callstackincubator/rock#740 ·
-
S: triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
RED ladder stopped @ 4db4ed91Đang mởarea:workflow bug ready-for-human
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
fil-donadoni/tolaria#6108 ·
Maintainer thường phản hồi trong vòng 1 ngày