mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
fix(agent): count compression restarts toward retry limit (#3070)
When context overflow triggers compression, the outer retry loop restarts via continue without incrementing retry_count. If compression reduces messages but not enough to fit the context window, this creates an infinite loop burning API credits: API call → overflow → compress → retry → overflow → compress → ... Increment retry_count on compression restarts so the loop exits after max_retries total attempts. Cherry-picked from PR #2766 by dieutx.
This commit is contained in:
parent
9d1e13019e
commit
9792bde31a
1 changed files with 5 additions and 0 deletions
|
|
@ -6637,6 +6637,11 @@ class AIAgent:
|
|||
if restart_with_compressed_messages:
|
||||
api_call_count -= 1
|
||||
self.iteration_budget.refund()
|
||||
# Count compression restarts toward the retry limit to prevent
|
||||
# infinite loops when compression reduces messages but not enough
|
||||
# to fit the context window.
|
||||
retry_count += 1
|
||||
restart_with_compressed_messages = False
|
||||
continue
|
||||
|
||||
if restart_with_length_continuation:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue