1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! O6: RepeatFuse — the hard rungs of the no-progress escalation ladder.
//!
//! The 2c salience-footer STOP (context/renderer.rs) is the SOFT rung: at ≥2 consecutive turns of
//! the identical tool call (same name AND args) it injects a `STOP:` line at the prompt's
//! peak-attention position and bets the model self-corrects. This module holds the config for the
//! two rungs above it, enforced in the state machine's gate (scheduler/state_machine/gate.rs):
//!
//! - **deny** (`deny_after`, default 5): the turn is rolled back like a governance deny and a
//! directive note — WHY it was denied, WHAT to do instead — is fed back to the model.
//! - **terminate** (`terminate_after`, default 8): the run ends with
//! [`TerminationReason::NoProgress`](crate::types::result::TerminationReason) after one final
//! no-tools report turn, so embedders can tell "looped with no progress" from `MaxTurns`.
//!
//! The fuse keys on the SAME per-turn signature the 2c STOP uses (non-meta `name(args)` joined),
//! so a legit loop varying its args reads as distinct progress on every rung. A signature-based
//! fuse deliberately does NOT catch args-varying loops — the token/turn budgets remain the
//! backstop there (any mechanical detector would false-positive real iteration).
use ;
/// Thresholds for the repeat fuse. `0` disables that rung individually; `enabled: false` disables
/// the whole fuse. Counting is per consecutive identical turn-signature: a different call (or the
/// same tool with different args) resets the streak to 1.