Skip to content

tests: pin the loop guard's stuck rule and abort cascade - #342

Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:tests-loopguard-abort-cascade
Open

Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:tests-loopguard-abort-cascade

Conversation

@Shizoqua

Copy link
Copy Markdown
Contributor

rules.is_stuck and rules.assess_abort decide when the loop guard redirects or stops a turn, but no test calls them directly: they are exercised through TurnGuard and the experiments' controllers. This adds tests/test_loopguard_rules.py, 21 tests that pin their rules with the default thresholds:

  • stuck needs every condition, each threshold inclusive: 20 turns, churn on one file (4) or scatter over several (3), 6 error outputs and stagnation 0.20; any one missing is not stuck;
  • with no judge, a stuck turn aborts only past the envelope;
  • the backstop (2.5x the envelope, or a cap-aware backstop_turns) aborts a stuck turn before the judge is asked, and a turn that is not stuck goes on past it;
  • the gate spends nothing below 18 turns or without a repeated failure, 8 errors or a turn past the envelope, unless gate_over_envelope is off;
  • only a stuck verdict at 0.7 confidence or more aborts; a productive, unsure, missing or failed verdict spares the turn, also past the envelope.

No code changes. All 21 pass on main. To check they guard something, I broke rules.py six ways (the repeated-failure condition dropped, the confidence threshold made exclusive, the backstop ignoring the heuristic, the envelope no longer opening the gate, the cap-aware backstop ignored, an unsure verdict aborting), and each one fails at least one of these tests.

python -m pytest tests -n 4 --dist worksteal -rfEs --tb=line
1588 passed, 41 skipped

The skips need Windows, a real agent CLI (Codex, Hermes, opencode) or aider, or a non-root user.

`rules.is_stuck` and `rules.assess_abort` decide when the loop guard redirects or stops a turn, but
no test calls them directly: they are exercised through `TurnGuard` and the experiments'
controllers. These tests pin their rules with the default thresholds:

- stuck needs every condition, each threshold inclusive: run 20 turns, churn on one file (4) or
  scatter over several (3), 6 error outputs, and stagnation 0.20; any one missing is not stuck;
- with no judge, a stuck turn aborts only past the envelope;
- the backstop (2.5x the envelope, or a cap-aware `backstop_turns`) aborts a stuck turn before the
  judge is asked, and a turn that is not stuck goes on past it;
- the gate spends nothing below 18 turns or without a repeated failure, 8 errors or a turn past
  the envelope (unless `gate_over_envelope` is off);
- only a stuck verdict at 0.7 confidence or more aborts; a productive, unsure, missing or failed
  verdict spares the turn, also past the envelope.

No behavior changes.
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.

1 participant