fix(qqbot): add MAX_RECONNECT_ATTEMPTS check for QQCloseError path#13461
Open
jkiwen wants to merge 7 commits intoNousResearch:mainfrom
Open
fix(qqbot): add MAX_RECONNECT_ATTEMPTS check for QQCloseError path#13461jkiwen wants to merge 7 commits intoNousResearch:mainfrom
jkiwen wants to merge 7 commits intoNousResearch:mainfrom
Conversation
…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
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.
问题
QQCloseError (非 4008) 的重新连接路径缺少
MAX_RECONNECT_ATTEMPTS上限检查,导致永久网络失败后 Bot 静默挂起数小时。修复
在
_listen_loop的QQCloseErrorexcept 块中添加MAX_RECONNECT_ATTEMPTS检查:测试
在本地 StepFun + QQBot 环境测试通过。
See: #13074