Skip to content

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

@Harrrryz

Description

@Harrrryz

Please read this first

  • Have you read the custom model provider docs? Yes.
  • Have you searched for related issues? Not found.

Describe the question

When using DeepSeek in thinking mode with tool calls via @openai/agents-extensions aisdk() (Vercel AI SDK bridge), the second request in the tool loop fails with:

Missing reasoning_content field in the assistant message at message index X

DeepSeek thinking mode requires clients to echo reasoning_content back to the API during the tool-call loop (see https://api-docs.deepseek.com/guides/thinking_mode#tool-calls). Our history/prompt serialization can send an assistant tool-call message without reasoning_content, triggering a 400.

Debug information

  • Package: @openai/agents-extensions
  • Runtime: Node.js 22+ (repro on Node 23.x)
  • Provider: @ai-sdk/deepseek
  • Thinking mode: either model="deepseek-reasoner" OR providerOptions.deepseek.thinking.type="enabled"

Repro steps

import { Agent, run, tool } from '@openai/agents';
import { aisdk } from '@openai/agents-extensions';
import { z } from 'zod';
import { createDeepSeek } from '@ai-sdk/deepseek';

const deepseek = createDeepSeek({ apiKey: process.env.DEEPSEEK_API_KEY! });
const model = aisdk(deepseek('deepseek-reasoner')); // thinking mode

const getWeather = tool({
  name: 'get_weather',
  description: 'Get the weather for a city',
  parameters: z.object({ city: z.string() }),
  execute: async ({ city }) => `sunny in ${city}`,
});

const agent = new Agent({
  name: 'Test',
  instructions: 'Use tools to answer.',
  tools: [getWeather],
  model,
});

await run(agent, 'What is the weather in San Francisco?');

Expected behavior

The tool loop completes and the agent returns a final answer.

Actual behavior

DeepSeek returns HTTP 400: Missing reasoning_content field in the assistant message ....

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions