Repository navigation
feat!: Anthropic 思考配置支持 display、显式关闭与交错思考 beta 头 - #115
Merged
Merged
Conversation
- WithThinkingDisabled 与 ThinkingConfig{Type:"disabled"} 改为显式发送
thinking{type:"disabled"}。Claude 5 系列不带 thinking 时默认思考,旧的
省略写法无法关闭;Claude 4.x 上两者等价
- 新增 WithThinkingBetweenTools,旧接口的 between_tools 类型也映射到它
- 新增 WithThinkingDisplay 与 ThinkingConfig.Display,发送 thinking.display;
与 disabled、between_tools 或未设置思考模式同时使用时在发送前报错
- 新增 WithInterleavedThinking,把 interleaved-thinking-2025-05-14 合并进
anthropic-beta,保留已有 beta 且去重,默认不发送
- 文档补充各代 Claude 的思考模式选择
BREAKING CHANGE: 关闭思考不再省略 thinking 字段,而是发送 {type:"disabled"}。
拒绝该值的模型(Claude Opus 5.5、Fable 5.x)不应再使用 WithThinkingDisabled。
Linear: TWI-6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
让 Anthropic Messages provider 能表达新版 Claude 的思考配置:
WithThinkingDisabled和WithThinking(ThinkingConfig{Type: "disabled"})以前都靠「不发 thinking 字段」表示关闭。Claude 5 系列不带 thinking 时默认开启自适应思考,所以旧写法在这些模型上关不掉,照样思考和计费。现在一律发送thinking: {type: "disabled"}。在 Claude 4.x 上,显式关闭和省略效果相同。between_tools:新增WithThinkingBetweenTools()。Claude Sonnet 5.5 拒绝disabled,要用这个类型关闭前置思考。旧接口传入between_tools类型也会映射到这里。display:新增WithThinkingDisplay(display)和ThinkingConfig.Display,发送thinking.display,取值为summarized或omitted。Claude Opus 4.7 及以后默认是omitted,思考块文本为空。需要展示思考内容的调用方可以要求summarized。display和disabled、between_tools同时使用,或没有设置思考模式时,会在请求发送前报错。WithInterleavedThinking(),把interleaved-thinking-2025-05-14合并进anthropic-beta,保留已有的 beta 并去重。Claude 4.5 及更早的预算模式要靠它在工具调用之间思考。官方 API 会忽略不支持的模型,但第三方 Anthropic 兼容端点不一定,所以默认不发。破坏性变更与迁移
关闭思考现在会发送
{type: "disabled"},不再省略字段:WithThinkingDisabled,否则会收到 400。disabled,需要调用方自行处理。Memoh 已有用
ThinkingConfig{Type: "disabled"}显式关闭的逻辑,但以前会被转成省略字段,从未真正发出。这次修改后它会按预期生效。关联
验证
disabled和between_tools的请求体;新旧接口的输出一致,新增between_tools和带display的对照;display随自适应和预算模式发送,并且不受选项先后顺序影响;三种非法组合都在发送前报错,测试服务器收不到请求;beta 头默认不发、开启后发送、与已有 beta 合并、大小写不同的同名 beta 去重。原有max_tokens矩阵测试未改动,仍然通过。go build ./...、go vet ./...、go vet -tags integration ./...、golangci-lint run ./...(0 issues)、go test ./... -short -race、internal/sdkdiff测试、go mod tidy无变化。display和 beta 头在官方 API 上的实际效果还需要用官方密钥验证。🤖 Generated with Claude Code