Skip to content

fix(qqbot): add MAX_RECONNECT_ATTEMPTS check for QQCloseError path#13461

Open
jkiwen wants to merge 7 commits intoNousResearch:mainfrom
jkiwen:fix/qqbot-reconnect-max-attempts
Open

fix(qqbot): add MAX_RECONNECT_ATTEMPTS check for QQCloseError path#13461
jkiwen wants to merge 7 commits intoNousResearch:mainfrom
jkiwen:fix/qqbot-reconnect-max-attempts

Conversation

@jkiwen
Copy link
Copy Markdown

@jkiwen jkiwen commented Apr 21, 2026

问题

QQCloseError (非 4008) 的重新连接路径缺少 MAX_RECONNECT_ATTEMPTS 上限检查,导致永久网络失败后 Bot 静默挂起数小时。

修复

_listen_loopQQCloseError except 块中添加 MAX_RECONNECT_ATTEMPTS 检查:

if backoff_idx >= MAX_RECONNECT_ATTEMPTS:
    logger.error("[%s] Max reconnect attempts reached (QQCloseError)", self._log_tag)
    return

测试

在本地 StepFun + QQBot 环境测试通过。

See: #13074

jkiwen and others added 7 commits April 18, 2026 22:54
…epFun, etc.)

Some APIs (StepFun, etc.) have stricter JSON validation than OpenRouter.
This fix ensures messages can be serialized without 'Unterminated string'
errors by sanitizing problematic characters in message content.

Fixes: https://github.com/NousResearch/hermes-agent/issues/XXXX
Use _validate_messages_json from auxiliary_client to sanitize prompt
messages before sending to the LLM. This prevents 'Unterminated string'
errors on strict API backends like StepFun during context compression.

This is similar to the fix in auxiliary_client.py for general
auxiliary LLM calls.

Testing: Import and basic function test passed
…id JSON

The original code truncated tool_calls.arguments directly, breaking JSON validity:
  {"code": "long_code..."} → {"code": "long_cod...[truncated]"
                            Missing closing brace and quote

New approach:
1. Parse arguments as JSON
2. Truncate string values (max 200 chars)
3. Re-serialize to valid JSON

This prevents 'Unterminated string' errors on strict API backends (StepFun, etc.)

Risk: String content in tool_calls is truncated, but the JSON remains valid.
…ified

The modified variable was referenced outside its scope when no tool_calls
were modified, causing UnboundLocalError.

Fix: Initialize modified = False before the loop and check before updating msg.
Fixes silent hang after permanent network failure.

Cherry-picked from PR NousResearch#13074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant