-
Notifications
You must be signed in to change notification settings - Fork 529
feat(agents-extensions): #628 add Anthropic extended thinking support #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(agents-extensions): #628 add Anthropic extended thinking support #742
Conversation
…openai#628 Add support for capturing Claude's extended thinking (reasoning) blocks when using the AI SDK adapter with Anthropic models.
🦋 Changeset detectedLatest commit: d82623f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (reasoningBlock.text) { | ||
| outputs.push({ | ||
| type: 'reasoning', | ||
| id: reasoningId !== 'default' ? reasoningId : undefined, | ||
| content: [{ type: 'input_text', text: reasoningBlock.text }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve reasoning metadata even when no text streamed
In the streamed path we only emit a reasoning item when reasoningBlock.text is truthy. For streams where Anthropic returns a reasoning signature but redacts the thinking text (no deltas before the reasoning-end event), this branch is skipped and the reasoning item is omitted, so the signature in providerMetadata is dropped and cannot be echoed back on the next turn despite the PR’s goal of preserving it. Consider emitting a reasoning item even when the text is empty so providerData survives redacted thinking streams.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me update a code to preserve the signature even with empty text.
Co-authored-by: Kazuhiro Sera <seratch@openai.com>
Co-authored-by: Kazuhiro Sera <seratch@openai.com>
|
@codex review again |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
seratch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed this change enables ai-sdk layer to work with the thinking mode. Example model settings:
const modelSettings = {
providerData: {
providerOptions: {
anthropic: {
thinking: { type: 'enabled', budgetTokens: 32000 },
},
},
},
};
Summary
Fixes #628
This PR adds support for capturing Claude's extended thinking (reasoning) blocks when using the AI SDK adapter with Anthropic models.
Changes
reasoningparts from AI SDK responses and output them asReasoningItemobjectsreasoning-start,reasoning-delta,reasoning-endevents to accumulate thinking contentproviderDatafor multi-turn conversation supportTest plan
References for this Issue