fix(chat): 检测并提示被静默吞掉的 run 错误 (#206)
当上游 hermes-agent 的 agent 层捕获了 LLM 错误(如无效 API key、 模型不被 provider 支持)后,gateway 仍会发送 run.completed 事件, 但 output 为空、usage 为零。前端因此误认为成功,UI 完全无任何 错误提示。 本次修复在 chat store 的 SSE 处理中加入两个 per-run 标志: - runProducedAssistantText:仅 reasoning/thinking/message.delta 置位 - runHadToolActivity:仅 tool.started/tool.completed 置位 run.completed 时: 1. 兜底渲染:若本次 run 没有 assistant 文本但 evt.output 非空, 将 output 作为 assistant 消息落盘(兼容某些只在 completed 事件给出最终文本的 provider)。 2. 静默错误检测:若三者均不成立(无 assistant 文本 + 无 tool 活动 + output 空),追加一条 system 消息提示用户检查 hermes-agent 日志。usage=0 不再作为强条件,避免某些 provider 或本地模型不返回 usage 时的误报。 api/hermes/chat.ts 给 RunEvent 增加 output 字段类型。 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -30,6 +30,9 @@ export interface RunEvent {
|
||||
preview?: string
|
||||
timestamp?: number
|
||||
error?: string
|
||||
/** Final response text on `run.completed`. May be empty/null if the agent
|
||||
* silently swallowed an upstream error — see chat store for fallback. */
|
||||
output?: string | null
|
||||
usage?: {
|
||||
input_tokens: number
|
||||
output_tokens: number
|
||||
|
||||
Reference in New Issue
Block a user