问题描述
使用 AionRS 连接 DeepSeek V4 Pro 模型时,模型会长时间思考但最终可能无法产生工具调用(返回 finish_reason: "length"),表现为"一直在思考但不执行任务"。
根因分析
1. OpenAI provider 无法发送 thinking 配置
DeepSeek V4 Pro 默认 thinking: {type: "enabled"},思考模式始终开启。但 AionRS 的 OpenAI 兼容路径:
- 只发送
reasoning_effort,不发送 thinking 对象
- 代码位置:
crates/aion-providers/src/openai.rs:250-266 的 build_body 方法
// 当前只发送了 reasoning_effort(第 262-264 行)
if let Some(effort) = &request.reasoning_effort {
body["reasoning_effort"] = json!(effort);
}
// 缺少:body["thinking"] = json!({"type": "enabled"});
对比 Anthropic provider(anthropic.rs:84-85)是发送了 thinking 配置的。
2. supports_thinking 对 OpenAI 路径固定为 false
crates/aion-config/src/compat.rs:99 中 openai_defaults() 设 supports_thinking: Some(false),导致即使用户通过 SetConfig 协议发送了 thinking + thinking_budget,也会被 engine.rs:284 拦截:
if !self.compat.supports_thinking() {
changes.push("thinking: not supported by current provider".to_string());
}
3. 默认 max_tokens 偏小
crates/aion-config/src/config.rs:226 中 default_max_tokens() 返回 8192。DeepSeek V4 Pro 的思考 token 和输出 token 共享这个配额,模型可能在思考阶段就消耗了 6000-7000 token,剩余不足以产生工具调用。
4. 实际影响验证
从用户会话数据看:
- DeepSeek V4 Pro:151 条消息,总输出 28K token,平均每轮仅 ~186 token(大量被思考消耗)
- DeepSeek V4 Flash:68 条消息,总输出 75K token,平均每轮 ~1108 token(Flash 思考开销小)
AionRS 启动命令中缺少 --max-tokens 参数:
aionrs --json-stream --provider openai --model deepseek-v4-pro --base-url https://api.deepseek.com
建议修复
- OpenAI provider 支持发送
thinking 配置 — 当 request.thinking 为 Some(Enabled { budget_tokens }) 时,在请求体中添加 "thinking": {"type": "enabled"};为 Some(Disabled) 时添加 "thinking": {"type": "disabled"}
- 更新
supports_thinking 机制 — 不应全局写死为 false,应允许用户/模型级别的 override,或者至少让 DeepSeek 等支持 thinking 的 OpenAI 兼容模型能配置
- 提高默认 max_tokens — 对于已知的 thinking 模型,默认值至少应该设到 16384 或更高
- 支持
--max-tokens 命令行参数 — AionUI 等宿主客户端可以通过此参数覆盖默认值
环境信息
- AionRS 版本:v0.1.15
- 模型:deepseek-v4-pro
- 运行方式:通过 AionUI 以
--json-stream 模式启动
问题描述
使用 AionRS 连接 DeepSeek V4 Pro 模型时,模型会长时间思考但最终可能无法产生工具调用(返回
finish_reason: "length"),表现为"一直在思考但不执行任务"。根因分析
1. OpenAI provider 无法发送
thinking配置DeepSeek V4 Pro 默认
thinking: {type: "enabled"},思考模式始终开启。但 AionRS 的 OpenAI 兼容路径:reasoning_effort,不发送thinking对象crates/aion-providers/src/openai.rs:250-266的build_body方法对比 Anthropic provider(
anthropic.rs:84-85)是发送了 thinking 配置的。2.
supports_thinking对 OpenAI 路径固定为 falsecrates/aion-config/src/compat.rs:99中openai_defaults()设supports_thinking: Some(false),导致即使用户通过SetConfig协议发送了thinking+thinking_budget,也会被engine.rs:284拦截:3. 默认 max_tokens 偏小
crates/aion-config/src/config.rs:226中default_max_tokens()返回 8192。DeepSeek V4 Pro 的思考 token 和输出 token 共享这个配额,模型可能在思考阶段就消耗了 6000-7000 token,剩余不足以产生工具调用。4. 实际影响验证
从用户会话数据看:
AionRS 启动命令中缺少
--max-tokens参数:建议修复
thinking配置 — 当request.thinking为Some(Enabled { budget_tokens })时,在请求体中添加"thinking": {"type": "enabled"};为Some(Disabled)时添加"thinking": {"type": "disabled"}supports_thinking机制 — 不应全局写死为 false,应允许用户/模型级别的 override,或者至少让 DeepSeek 等支持 thinking 的 OpenAI 兼容模型能配置--max-tokens命令行参数 — AionUI 等宿主客户端可以通过此参数覆盖默认值环境信息
--json-stream模式启动