fix(conductor): surface LLM error to user when conductor falls silent (#342) - #414
Merged
lsdefine merged 1 commit intoMay 18, 2026
Conversation
…lsdefine#342) When a single LLM provider goes down mid-task (auth, network, quota, etc.), the conductor falls completely silent: MixinSession yields errors as text chunks (not Python exceptions), so the existing try/except guard in conductor_loop never triggers, and the conductor's only way to talk to the user (LLM-decided POST /chat tool call) is dead. Add a tiny watchdog: monitor_conductor_queue now returns the conductor agent's final done text, and conductor_loop scans the tail-1000-char window for "!!!Error:" — the prefix llmcore uses for unrecoverable errors. Tail window (not whole text) avoids false positives from earlier turns; using a character window (not last-line) matches ga.do_no_tool's content[-100:] style and tolerates the decoration (fence + "[Info] Final response to user.") that do_no_tool appends after the error chunk when its own short window check misses. When detected, push the matched error line as a system chat message so the user knows what happened. A dedup check prevents repeated warnings if multiple events fail in succession. +16 -4 lines. Only frontends/conductor.py touched. No agent_loop / llmcore changes; other frontends unaffected.
RocketLi
pushed a commit
to RocketLi/GenericAgent
that referenced
this pull request
May 18, 2026
…lsdefine#342) (lsdefine#414) When a single LLM provider goes down mid-task (auth, network, quota, etc.), the conductor falls completely silent: MixinSession yields errors as text chunks (not Python exceptions), so the existing try/except guard in conductor_loop never triggers, and the conductor's only way to talk to the user (LLM-decided POST /chat tool call) is dead. Add a tiny watchdog: monitor_conductor_queue now returns the conductor agent's final done text, and conductor_loop scans the tail-1000-char window for "!!!Error:" — the prefix llmcore uses for unrecoverable errors. Tail window (not whole text) avoids false positives from earlier turns; using a character window (not last-line) matches ga.do_no_tool's content[-100:] style and tolerates the decoration (fence + "[Info] Final response to user.") that do_no_tool appends after the error chunk when its own short window check misses. When detected, push the matched error line as a system chat message so the user knows what happened. A dedup check prevents repeated warnings if multiple events fail in succession. +16 -4 lines. Only frontends/conductor.py touched. No agent_loop / llmcore changes; other frontends unaffected.
lsdefine
pushed a commit
that referenced
this pull request
Jul 23, 2026
…#342) (#414) When a single LLM provider goes down mid-task (auth, network, quota, etc.), the conductor falls completely silent: MixinSession yields errors as text chunks (not Python exceptions), so the existing try/except guard in conductor_loop never triggers, and the conductor's only way to talk to the user (LLM-decided POST /chat tool call) is dead. Add a tiny watchdog: monitor_conductor_queue now returns the conductor agent's final done text, and conductor_loop scans the tail-1000-char window for "!!!Error:" — the prefix llmcore uses for unrecoverable errors. Tail window (not whole text) avoids false positives from earlier turns; using a character window (not last-line) matches ga.do_no_tool's content[-100:] style and tolerates the decoration (fence + "[Info] Final response to user.") that do_no_tool appends after the error chunk when its own short window check misses. When detected, push the matched error line as a system chat message so the user knows what happened. A dedup check prevents repeated warnings if multiple events fail in succession. +16 -4 lines. Only frontends/conductor.py touched. No agent_loop / llmcore changes; other frontends unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
跟踪 #342 时发现 conductor 这一侧也存在类似的静默死亡路径:用户共享同一个 LLM 供应商时,subagent 跑到一半挂了(401 / 超时 / 限额),conductor 被唤醒去回报,但它自己的 LLM 也已不可用——无法主动调用 POST /chat 与用户沟通。结果是浏览器完全静默,没有任何反馈。
排查结果:`MixinSession._raw_ask` 在所有重试耗尽后并不抛异常,而是将 `!!!Error: HTTP 401: ...` 作为普通文本 chunk yield 出去,因此 conductor_loop 外层的 try/except 永远拦不到。conductor 的唯一发声途径是它自己 LLM 决定调用 POST /chat——LLM 不可用时这条路径同时失效。旧版 `monitor_conductor_queue` 又只是消费掉 done 事件,没有向调用方传递任何信号。
改动仅 `frontends/conductor.py`,+16 -4:
不涉及 `llmcore.py` / `agent_loop.py` / `agentmain.py`;其他 frontend(chatapp、TUI)不受影响。
本地用 mock proxy 复现:透传 ollama.com,检测到 flag 文件后切回 401。流程为启动 conductor → 派一个 subagent → 在 subagent 执行期间创建 flag → subagent 完成唤醒 conductor → conductor 调用 LLM 失败。修复前完全静默;修复后浏览器收到 `⚠ LLM 暂不可用:!!!Error: HTTP 401: {...}` 系统消息。
附注:底层 `ga.py:461` 的 `content[-100:]` 窗口过短,长错误字符串会被截断导致 do_no_tool 误判为正常响应。这是一个独立 bug,本 PR 仅在 conductor 层做兜底,不在此处合并修复。