Skip to content

Add mechanical stuck-loop guard for agent loops#254

Merged
JE-Chen merged 1 commit into
devfrom
feat/loop-guard-batch
Jun 20, 2026
Merged

Add mechanical stuck-loop guard for agent loops#254
JE-Chen merged 1 commit into
devfrom
feat/loop-guard-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 20, 2026

Copy link
Copy Markdown
Member

Computer-use agent batch (from multi-agent web research; verified absent). Full layers + tests + EN/Zh v46 docs + README.

Feature (utils/loop_guard, pure-stdlib)

  • LoopGuard watches the (tool, args, result) stream and flags three stuck-loop patterns: repeat (same call N times in a row), ping_pong (A-B-A-B alternation), no_op (observation digest never changes), escalating okwarncritical by run length (configurable thresholds, bounded window). digest_result makes a stable short hash of a screenshot/observation (bytes or JSON-able).
  • Why: the dominant computer-use failure mode is an agent burning budget on a no-effect loop the model can't see; a step/time budget can't distinguish a productive loop from a stuck one, and trajectory eval is offline. This is the missing in-loop, mechanical detector.
  • Executor AC_loop_guard_observe / AC_loop_guard_reset (module-level default guard); MCP ac_*; Builder under Agent.

Verification

  • 10 tests pass (repeat escalation ok/warn/critical, repeat count, distinct-args not-repeat, ping_pong, no_op on unchanged digest, reset, digest stability for bytes/dict, executor round-trip, wiring, facade); ruff clean; radon no CC≥C; bandit clean; PySide6-free.
  • Stacked on coordinate-space (Add coordinate-space mapping (model grid <-> physical pixels) #253); rebased cleanly onto dev.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 58 complexity · 0 duplication

Metric Results
Complexity 58
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 76c6eb3 into dev Jun 20, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/loop-guard-batch branch June 20, 2026 05:50
@sonarqubecloud

Copy link
Copy Markdown

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