Skip to content

关于多轮调用deepseek-v4-pro出现的缺少reasoning_content字段问题,我这里有一个解决办法 #317

@H-1234-S

Description

@H-1234-S

描述:
使用 anthropic() 适配器配置 DeepSeek 模型时(通过 baseUrl: 'https://api.deepseek.com/anthropic/v1'),AgenticModel.responseParser 在处理响应时崩溃:

TypeError: acc is not iterable
at AgenticModel.responseParser (chunk-XXX.js:392)
at Array.reduce ()

复现代码:
const agent = createAgent({
name: "test",
model: anthropic({
model: "deepseek-chat",
apiKey: process.env.DEEPSEEK_API_KEY,
baseUrl: 'https://api.deepseek.com/anthropic/v1',
defaultParameters: { temperature: 0.3, max_tokens: 16000 }
}),
tools: [...]
});

const network = createNetwork({
name: "test-network",
agents: [agent],
});
await network.run(message); // <- TypeError here

根因分析:
responseParser 第 392 行:
return ((_b = input == null ? void 0 : input.content) != null ? _b : []).reduce((acc, item) => {

代码假设 input.content 是数组,但 DeepSeek 的 Anthropic 兼容端点返回的 content 可能:

  • 是字符串(而非 [{type:"text", text:"..."}])
  • 是其他非 iterable 类型

当 content 是字符串时,[...acc, ...item] 展开失败,导致 acc is not iterable。

环境:

  • @inngest/agent-kit: latest
  • @inngest/ai: latest
  • Node.js: 20+
  • DeepSeek API: api.deepseek.com/anthropic/v1

期望行为:
responseParser 应兼容不同模型返回的多种 content 格式,或在文档中明确说明支持的格式。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions