Skip to content

fix(agent): count compression restarts toward retry limit#3070

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-7d7ac769
Mar 25, 2026
Merged

fix(agent): count compression restarts toward retry limit#3070
teknium1 merged 1 commit intomainfrom
hermes/hermes-7d7ac769

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

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 → ... (forever at retry_count=0)

compression_attempts limits inner compression attempts, but the outer while retry_count < max_retries loop never exits.

Fix

Increment retry_count on compression restarts so the loop has a hard exit after max_retries total attempts. Also explicitly resets restart_with_compressed_messages at the continue site for clarity.

Note: restart_with_length_continuation (truncated response continuation) correctly does NOT increment retry_count — that's normal behavior, not an error.

Cherry-picked from PR #2766 by @dieutx.

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.
@teknium1 teknium1 merged commit 9792bde into main Mar 25, 2026
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…ch#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 NousResearch#2766 by dieutx.
StreamOfRon pushed a commit to StreamOfRon/hermes-agent that referenced this pull request Mar 29, 2026
…ch#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 NousResearch#2766 by dieutx.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant