Skip to content

Comments

Fix infinite loop bug in rules system when promise tags aren't recogn…#96

Merged
nhorton merged 1 commit intomainfrom
claude/fix-rules-infinite-loop-JntE8
Jan 21, 2026
Merged

Fix infinite loop bug in rules system when promise tags aren't recogn…#96
nhorton merged 1 commit intomainfrom
claude/fix-rules-infinite-loop-JntE8

Conversation

@nhorton
Copy link
Contributor

@nhorton nhorton commented Jan 21, 2026

The rules system would create an infinite loop when:

  1. Rules with compare_to: base fire when src/ files are modified
  2. The assistant responds with Rule Name tags
  3. The stop hook runs again and fires the same rules, ignoring promise tags

Root cause: When a PROMPT action rule fires, a queue entry is created with QUEUED status. The hook only skipped rules with PASSED or SKIPPED status, so QUEUED rules would fire again even though they had already been shown to the agent. The promise tag mechanism relies on reading the transcript, which may not be available or may not contain the current response yet.

Fix: Skip PROMPT rules that already have a QUEUED entry, since the agent has already seen this rule and doesn't need to see it again.

Added tests:

  • test_queued_prompt_rule_does_not_refire
  • test_rule_fires_again_after_queue_cleared
  • test_promise_tag_still_prevents_firing

…ized

The rules system would create an infinite loop when:
1. Rules with compare_to: base fire when src/ files are modified
2. The assistant responds with <promise>Rule Name</promise> tags
3. The stop hook runs again and fires the same rules, ignoring promise tags

Root cause: When a PROMPT action rule fires, a queue entry is created with
QUEUED status. The hook only skipped rules with PASSED or SKIPPED status,
so QUEUED rules would fire again even though they had already been shown
to the agent. The promise tag mechanism relies on reading the transcript,
which may not be available or may not contain the current response yet.

Fix: Skip PROMPT rules that already have a QUEUED entry, since the agent
has already seen this rule and doesn't need to see it again.

Added tests:
- test_queued_prompt_rule_does_not_refire
- test_rule_fires_again_after_queue_cleared
- test_promise_tag_still_prevents_firing
@nhorton nhorton merged commit 81e367b into main Jan 21, 2026
4 checks passed
@nhorton nhorton deleted the claude/fix-rules-infinite-loop-JntE8 branch January 21, 2026 16:38
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.

2 participants