feat: 升级至 v0.3.16 — 工单修复 51 项 + 审查修复 30 项(安全加固/适配器/工具系统/数据层/前端)
This commit is contained in:
@@ -46,6 +46,11 @@ export function buildOpenAICompatibleMessages(
|
||||
content: m.content,
|
||||
};
|
||||
|
||||
// 注意:图片(多模态)处理不在此共享函数中。
|
||||
// DeepSeek 不支持多模态,images 被静默丢弃是正确行为。
|
||||
// Agnes/MiMo 各自的 toNativeRequest 中有独立的 images 处理。
|
||||
// 审查修复: #27 曾在此添加 images 处理,但 DeepSeek 不支持多模态会导致 API 400,已撤销。
|
||||
|
||||
// === Assistant 消息 ===
|
||||
if (m.role === 'assistant') {
|
||||
// 工具调用历史
|
||||
@@ -74,6 +79,10 @@ export function buildOpenAICompatibleMessages(
|
||||
: (typeof m.toolResult.result === 'string'
|
||||
? m.toolResult.result
|
||||
: JSON.stringify(m.toolResult.result));
|
||||
// #26 修复: 确保 tool 消息 content 不为 undefined
|
||||
// JSON.stringify(undefined) 返回 undefined(非字符串),会导致 content 字段在序列化后消失
|
||||
// OpenAI/DeepSeek/Agnes API 严格要求 tool 消息必须有 content 字段,缺失会返回 400
|
||||
if (msg.content === undefined) msg.content = '';
|
||||
}
|
||||
|
||||
return msg;
|
||||
|
||||
@@ -52,8 +52,14 @@ function* flushToolCallBuffer(
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
};
|
||||
} catch {
|
||||
// JSON 解析失败,跳过该工具调用
|
||||
} catch (err) {
|
||||
// #25 修复: 不再静默丢弃 JSON 解析失败的工具调用
|
||||
// 审查修复: 不再 yield ERROR 事件,因为 Engine 收到 ERROR 会 throw 中断整个请求,
|
||||
// 导致一个好的工具调用 JSON 解析失败就丢弃所有工具调用。
|
||||
// 改为 log.warn 记录后 continue 跳过这条坏的工具调用,继续处理 buffer 中剩余的。
|
||||
const rawPreview = buf.argsBuffer?.slice(0, 200) ?? '';
|
||||
log.warn(`[SSE] Tool call JSON parse failed: ${(err as Error).message}`, rawPreview);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
toolCallsBuffer.clear();
|
||||
|
||||
Reference in New Issue
Block a user