fix(bot+auto_heal): stop auto_heal from killing bot during slow LLM calls

Root cause of 'no response': auto_heal restart_zhiwei_bot fired whenever
inbound>0 + outbound=0 + errors>0 — which is exactly the normal state while
the bot waits for a slow LLM call (agent tool-use turns take 1-10 min).
Restart killed the in-flight LLM call -> user never got reply -> next cron
cycle saw same state -> restart again. Death loop (fired 22:30,22:35,22:40,
22:45,22:50,23:35).

Fixes:
- CALL_HERMES_TIMEOUT 180s -> 600s (agent tool calls need minutes)
- health(): parse last_inbound/outbound timestamps from journal
- auto_heal: restart bot ONLY if last inbound >600s old with no outbound
  since (truly stuck), plus 600s bot-restart cooldown
- slow-but-normal state now logs bot_busy_not_stuck instead of killing
This commit is contained in:
hmo
2026-07-19 23:43:28 +08:00
parent bb1529909b
commit cb334ddd54
2 changed files with 54 additions and 10 deletions
+2 -2
View File
@@ -52,8 +52,8 @@ ACK_DELAY = 120 # 真卡死才提示(普通 LLM 冷启动 20-100s 不应触
GATEWAY_URL = ""
GATEWAY_API_KEY = ""
GATEWAY_SESSION_ID = ""
GATEWAY_DEADLINE_SECONDS = 180
CALL_HERMES_TIMEOUT = 180
GATEWAY_DEADLINE_SECONDS = 600
CALL_HERMES_TIMEOUT = 600 # agent 带工具调用(读文件/查数据)需几分钟
FALLBACK_REPLY = "请稍等,我在处理..."
# ── 图片 OCR 配置(截图消息 → SenseNova vision)──