max_turns defaults to 200 (crates/hx-core/src/agent.rs) and nothing detects a loop. A confused model can repeat the same failing call while context grows. Code reading only; no transcript shows this happening yet.
Change
In the tool loop, track (tool, args hash, result hash). On the 3rd identical consecutive repeat, append to the tool result: "This call already returned the same result twice; change approach or ask the user." Optionally add a soft per-run token budget that emits an Event::Info warning (configurable, off by default).
Exempt bash calls that are plausibly polling (a command that includes a sleep, or one with an explicit timeout).
Effect
Helps only in the tail cases. Rate unknown; check real sessions for repeats first (count identical consecutive calls in the session file).
Risk
False positives on legitimate retries (e.g. rerunning a flaky test).
Verify
Unit test with a fake provider that issues the same call 4 times; assert the hint appears on the 3rd result and not before.
## Problem
`max_turns` defaults to 200 (`crates/hx-core/src/agent.rs`) and nothing detects a loop. A confused model can repeat the same failing call while context grows. Code reading only; no transcript shows this happening yet.
## Change
In the tool loop, track `(tool, args hash, result hash)`. On the 3rd identical consecutive repeat, append to the tool result: "This call already returned the same result twice; change approach or ask the user." Optionally add a soft per-run token budget that emits an `Event::Info` warning (configurable, off by default).
Exempt `bash` calls that are plausibly polling (a command that includes a sleep, or one with an explicit timeout).
## Effect
Helps only in the tail cases. Rate unknown; check real sessions for repeats first (count identical consecutive calls in the session file).
## Risk
False positives on legitimate retries (e.g. rerunning a flaky test).
## Verify
Unit test with a fake provider that issues the same call 4 times; assert the hint appears on the 3rd result and not before.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
max_turnsdefaults to 200 (crates/hx-core/src/agent.rs) and nothing detects a loop. A confused model can repeat the same failing call while context grows. Code reading only; no transcript shows this happening yet.Change
In the tool loop, track
(tool, args hash, result hash). On the 3rd identical consecutive repeat, append to the tool result: "This call already returned the same result twice; change approach or ask the user." Optionally add a soft per-run token budget that emits anEvent::Infowarning (configurable, off by default).Exempt
bashcalls that are plausibly polling (a command that includes a sleep, or one with an explicit timeout).Effect
Helps only in the tail cases. Rate unknown; check real sessions for repeats first (count identical consecutive calls in the session file).
Risk
False positives on legitimate retries (e.g. rerunning a flaky test).
Verify
Unit test with a fake provider that issues the same call 4 times; assert the hint appears on the 3rd result and not before.