Skip to content

Conversation

@Harrrryz
Copy link
Contributor

@Harrrryz Harrrryz commented Dec 19, 2025

Summary

Fixes DeepSeek thinking-mode tool-call loops when using the AI SDK bridge (aisdk()).

DeepSeek requires reasoning_content to 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", or
  • providerOptions.deepseek.thinking.type === "enabled".

Test plan

  • pnpm lint
  • pnpm build
  • pnpm -r build-check
  • pnpm test

Issue number

Closes #791

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run pnpm test and pnpm test:examples
    • (If you made a major change) I've run pnpm test:integration
  • I've made sure tests pass

@changeset-bot
Copy link

changeset-bot bot commented Dec 19, 2025

🦋 Changeset detected

Latest commit: c3c9fb2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@openai/agents-extensions Patch

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

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines +240 to +244
currentAssistantMessage = {
role: 'assistant',
content: [],
providerOptions: {
...(item.providerData ?? {}),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@seratch seratch changed the title fix(agents-extensions): support DeepSeek thinking tool calls fix: #791 support DeepSeek thinking tool calls Dec 19, 2025
@seratch seratch added this to the 0.3.x milestone Dec 19, 2025
@seratch seratch marked this pull request as draft December 19, 2025 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeepSeek thinking-mode tool calls fail with Missing reasoning_content when using aisdk()

2 participants