fix(#41400): add circuit breaker to prevent tirith retry loops - #41423
Closed
iamlukethedev wants to merge 1 commit into
Closed
fix(#41400): add circuit breaker to prevent tirith retry loops#41423iamlukethedev wants to merge 1 commit into
iamlukethedev wants to merge 1 commit into
Conversation
…loops Prevent infinite retry loops when tirith binary is misconfigured or unavailable, which causes 20+ minute agent hangs and blocks user message delivery. Implementation: - Track consecutive failures with module-level counter - After 3 consecutive failures (OSError, TimeoutExpired, or unexpected exit code), disable tirith for the session to prevent retry loops - Circuit breaker is thread-safe with mutex lock - Reset counter on success to allow recovery if tirith becomes available Behavior: - First 3 failures: return fail-open/fail-closed based on config - Subsequent failures: always return fail-open (allow) with circuit breaker message - Fixes NousResearch#41400 - prevents 2,704+ crashes and hangs on agent startup Test coverage: 100 tirith-related tests pass, including new regression tests for circuit breaker activation and reset logic.
tonydwb
approved these changes
Jun 7, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Reviewed PR #41423: fix(#41400): add circuit breaker to prevent tirith retry loops
✅ Approve
- Adds a circuit-breaker pattern to stop retry amplification in tirith calls, which matches the reported failure mode.
- Guardrails appear to target the exact retry entrypoint.
Reviewed in batch on 2026-06-08
Collaborator
|
Merged via #52997. Your circuit breaker approach was considered but #41446 by @kyssta-exe was chosen as the base — simpler (66 lines vs 262), no placeholder tests, matches the existing lock-free pattern. Thanks for the contribution! |
1 task
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.
Summary
Fixes critical issue where misconfigured or unavailable Tirith binary causes infinite retry loops, leading to:
Root Cause
When
tirith_pathpoints to a non-existent binary:check_command_security()callssubprocess.run()with bad pathfail_open: truesilently allows the tool to proceedSolution: Circuit Breaker
Add circuit breaker pattern to prevent retry loops:
Changes
tools/tirith_security.py:
_consecutive_failures,_circuit_breaker_disabled,_circuit_breaker_lockcheck_command_security()test_tirith_security.py:
tests/tools/test_tirith_startup_validation.py:
Testing
✅ 100 Tirith-related tests pass
✅ 8 new regression tests for circuit breaker
✅ All existing tests updated and passing
✅ Manual verification of circuit breaker activation
Fixes #41400