-
Notifications
You must be signed in to change notification settings - Fork 531
fix: #791 support DeepSeek thinking tool calls #792
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: c3c9fb2 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
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| currentAssistantMessage = { | ||
| role: 'assistant', | ||
| content: [], | ||
| providerOptions: { | ||
| ...(item.providerData ?? {}), |
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 tool providerOptions when merging DeepSeek reasoning
In DeepSeek thinking mode we now create the assistant message in the reasoning branch, setting providerOptions from the reasoning item. When the subsequent function_call arrives, the message already exists so its providerOptions are never updated with the tool call’s providerData. This means any tool-level provider options (e.g., cache control or provider-specific flags) are dropped at the message scope whenever a reasoning item precedes the tool call in thinking mode, diverging from previous behavior where tool-call providerOptions were applied to the message. Consider updating the existing currentAssistantMessage with the tool call’s providerData so DeepSeek thinking-mode tool calls retain their message-level options.
Useful? React with 👍 / 👎.
Summary
Fixes DeepSeek thinking-mode tool-call loops when using the AI SDK bridge (
aisdk()).DeepSeek requires
reasoning_contentto be echoed back to the API on assistant messages during thinking-mode tool calls. In our AI SDK prompt serialization, reasoning could be emitted as a separate assistant message, leaving the assistant tool-call message without reasoning. This PR merges reasoning parts into the same assistant message as subsequent tool calls, but only when thinking mode is enabled via:modelId === "deepseek-reasoner", orproviderOptions.deepseek.thinking.type === "enabled".Test plan
pnpm lintpnpm buildpnpm -r build-checkpnpm testIssue number
Closes #791
Checks
pnpm testandpnpm test:examplespnpm test:integration