binary-husky/gpt_academic · error · RuntimeError

程序终止。

Error message

程序终止。

What it means

Watchdog of the Slack-relay Claude streaming loop: while iterating claude_handle.stream_chat(...) yields, if time.time() - observe_window[1] exceeds watch_dog_patience (5 s), the loop raises RuntimeError('程序终止。') to kill a stalled generation thread.

Source

Thrown at request_llms/bridge_stackclaude.py:262

    history_feedin = []
    for i in range(len(history) // 2):
        history_feedin.append([history[2 * i], history[2 * i + 1]])

    watch_dog_patience = 5  # 看门狗 (watchdog) 的耐心, 设置5秒即可
    response = ""
    observe_window[0] = "[Local Message] 等待Claude响应中 ..."
    for response in claude_handle.stream_chat(
        query=inputs,
        history=history_feedin,
        system_prompt=sys_prompt,
        max_length=llm_kwargs["max_length"],
        top_p=llm_kwargs["top_p"],
        temperature=llm_kwargs["temperature"],
    ):
        observe_window[0] = preprocess_newbing_out_simple(response)
        if len(observe_window) >= 2:
            if (time.time() - observe_window[1]) > watch_dog_patience:
                raise RuntimeError("程序终止。")
    return preprocess_newbing_out_simple(response)


def predict(
    inputs,
    llm_kwargs,
    plugin_kwargs,
    chatbot,
    history=[],
    system_prompt="",
    stream=True,
    additional_fn=None,
):
    """
    单线程方法
    函数的说明请见 request_llms/bridge_all.py
    """
    chatbot.append((inputs, "[Local Message] 等待Claude响应中 ..."))

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Retry the request; transient Slack rate limits clear quickly
  2. Check Slack API status and auth.test the token to rule out revocation
  3. Reduce polling frequency in get_reply (sleep > 0.5s) or add jitter to avoid 429s
  4. If replies legitimately take >5s to first token, raise watch_dog_patience locally

Example fix

# before
watch_dog_patience = 5

# after
watch_dog_patience = 60  # Slack relay has high first-token latency
Defensive patterns

Strategy: retry

Try / catch

try:
    for r in claude_handle.stream_chat(...):
        observe_window[0] = r
except RuntimeError as e:
    if str(e) == '程序终止。' and retries_left:
        retries_left -= 1
        continue  # rebuild handle and retry
    raise

Prevention

When it happens

Trigger: stream_chat stops yielding for more than 5 seconds during predict_no_ui_long_connection in request_llms/bridge_stackclaude.py:262 — Slack API hang, rate limiting on the polling loop (get_reply polls every 0.5s), dropped connection, or Claude bot never replying so no yields occur.

Common situations: Slack 429 rate limit on conversations_history polling; Slack outage; the Claude Slack bot stuck in 'Typing…' forever; user token losing access mid-session.

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/6e611f4fadcc99f8. Report an issue: GitHub.