缺陷 / 高 / LLM 适配器
electron/harness/adapters/shared/openai-format.ts
构建 OpenAI 兼容消息时:
const message = { role: 'tool', content: toolResult.content ?? undefined, // 错误 tool_call_id: toolCall.id, };
当 toolResult.content 为 null 或空时,赋为 undefined,序列化后字段消失。 OpenAI / DeepSeek / Agnes API 严格要求 tool 消息必须有 content 字段,缺失会返回 400:
toolResult.content
undefined
content
Invalid value for 'messages[].content': field is required
const message = { role: 'tool', content: toolResult.content ?? '', // 空字符串而非 undefined tool_call_id: toolCall.id, };
或保留错误信息:
content: toolResult.content ?? toolResult.error ?? '',
project_memory.md 已要求:
Assistant messages with tool_calls must set content to null (not empty string) to avoid API 400 errors
但 tool 角色消息与 assistant 不同,必须有非空 content。
No dependencies set.
The note is not visible to the blocked user.
问题类型
缺陷 / 高 / LLM 适配器
文件位置
electron/harness/adapters/shared/openai-format.ts问题描述
构建 OpenAI 兼容消息时:
当
toolResult.content为 null 或空时,赋为undefined,序列化后字段消失。OpenAI / DeepSeek / Agnes API 严格要求 tool 消息必须有
content字段,缺失会返回 400:影响
建议修复
或保留错误信息:
project_memory.md 已要求:
但 tool 角色消息与 assistant 不同,必须有非空 content。