Skip to content

Limit suggested checks to 3 failures per run - #101

Merged
vm-mishchenko merged 2 commits into
mainfrom
260520-spec-suggest-checks-max-failures
May 20, 2026
Merged

vm-mishchenko merged 2 commits into
mainfrom
260520-spec-suggest-checks-max-failures

Conversation

@vm-mishchenko

Copy link
Copy Markdown
Owner

Summary

Adds a failure counter to prevent the suggester LLM from being invoked indefinitely on broken suggested checks. After 3 consecutive failures within a single run, the suggested-checks block is skipped entirely, allowing spec retries to proceed directly to the commit step.

The counter is tracked in step context (suggest_failures), incremented when suggested checks fail, and cleared on commit success. Static verify hooks are unchanged. This prevents hallucinated checks from exhausting max_retries while maintaining the ability to retry the spec itself.

Test plan

Added four new tests in tests/draft/test_code_spec.py:

  1. test_suggest_failures_counter_increments_and_blocks_at_limit — verifies the counter increments from 0 → 1 → 2 → 3 across three failing suggest attempts, and asserts that neither _suggest_checks nor _run_suggested_checks is called once the limit is reached.

  2. test_suggest_failures_counter_unchanged_on_commit_failure — confirms the counter remains at 3 when the commit step fails (pre-commit hook), and the suggester is not called on that attempt.

  3. test_suggest_failures_counter_unchanged_on_static_verify_failure — confirms the counter is unchanged when static verify fails before reaching the suggest block.

  4. test_suggest_failures_not_written_when_suggest_disabled — confirms the counter key is never read or written when suggest_extra_checks=False.

Additionally verified: the counter is cleared to 0 on commit success.

Prevent infinite loops of failing suggested checks by tracking
failure count and stopping suggestions after 3 attempts while
allowing spec retries to continue.
…add missing tests

- Move `ctx.step_get(..., "suggest_failures", 0)` inside `if cfg["suggest_extra_checks"]:` — reviewer: disabled path must not touch the key per spec
- Assert `step_set` writes sequence `[1, 2, 3]` in counter-increments test — reviewer: persisted sequence was untested
- Add test for counter unchanged at 3 when commit fails — reviewer: commit-failure invariant was missing
- Add test for counter unchanged at 2 when static verify fails — reviewer: static-verify-failure invariant was missing
- Assert `step_get` not called for `suggest_failures` in disabled-mode test — reviewer: disabled path must not read the key
@vm-mishchenko
vm-mishchenko marked this pull request as ready for review May 20, 2026 19:12
@vm-mishchenko
vm-mishchenko merged commit f0b2acc into main May 20, 2026
1 check passed
@vm-mishchenko
vm-mishchenko deleted the 260520-spec-suggest-checks-max-failures branch May 22, 2026 05:50
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