- Home
- Skills
- Testing & Debugging
- Stuck Agent Loop Detection & Verify-Before-Done Gate
More screenshots
Works with the AI Agents you already use
Stuck Agent Loop Detection & Verify-Before-Done Gate
Stop wasting tokens on agents that cycle through the same failing fixes.
$5
Stuck Agent Loop Detection & Verify-Before-Done Gate
Example session with this skill installed
The agent has tried to fix a 'KeyError: user_id' three times and it keeps failing. Check if the agent is stuck and get a verdict.
- Read your context and instructions
- Compiled the stuck agent loop
I have analyzed the session log to check for looping or drifting behavior.
Stuck-Check Verdict
| Metric | Value |
|---|---|
| Verdict | LOOPING |
| Evidence | KeyError: 'user_id' detected 3 times in src/auth.py |
| Convergence | 0.22 (Low) |
| Impact | 4 files imported this module; full suite recommended |
The analysis shows the agent is trapped in a retry loop. It has attempted to patch src/auth.py three times without a successful test run, and the error remains identical. The impact analysis indicates that src/api/routes.py and tests/test_auth.py are directly affected by these changes.
DO NEXT:
- Stop editing
src/auth.pyimmediately. - Read
src/models/user.pyto verify the schema foruser_id. - Run a minimal reproduction script
python scripts/repro_key_error.pybefore attempting another fix.
Next steps
- Execute the suggested reproduction script to confirm the root cause.
- Check the imported files listed in the impact report for mismatched definitions.
- Once fixed, run
python scripts/read.py | python scripts/impact.py | python scripts/judge.py doneto verify.
Connects securely to your tools. The creator never sees your data.
About this skill
Stop wasting tokens on agents that cycle through the same failing fixes. When a coding agent hits a wall, it often tries the same patch repeatedly or claims a task is finished without ever running a test. This skill provides a local safety net that detects loops, drifts, and stalls before they drain your budget.
What it does
- Loop detection identifies when the same error occurs three or more times despite repeated edits.
- Drift monitoring flags sessions with significant line changes that have not been validated by a successful command.
- Stall alerts catch agents making numerous tool calls without performing edits or passing checks.
- Completion gating verifies that every modified file has been exercised by a passing test before allowing the agent to exit.
- Impact analysis lists which files and tests are affected by recent edits to ensure proper test coverage.
How it works
- The agent executes a three-part Python pipeline that reads the local session log of Claude Code, Cursor, or Gemini.
- An impact analyzer identifies which downstream files or tests need to be run based on the specific changes made.
- A judge evaluates the session data against a convergence score and issues a verdict:
LOOPING,DRIFTING,STALLED, orON_TRACK. - The agent follows the specific "DO NEXT" instruction provided by the verdict to break the cycle or verify the work.
Frameworks & tools
This tool uses a series of Python 3.8+ scripts that run locally within your repository. It natively supports session logs for Claude Code, Cursor, Codex CLI, and Gemini CLI, with a fallback JSONL format for other environments.
Why this beats prompting it yourself
Prompting an agent to "not loop" fails because the agent's internal state is often compromised by the loop itself. This skill uses an externalized script to analyze the actual session history objectively, providing a hard exit gate that standard system prompts cannot enforce.
Use cases
- Preventing "doom loops" where an agent applies and reverts the same fix repeatedly.
- Auditing long-running sessions to see where tokens were wasted on unproductive retries.
- Ensuring "Verify-Before-Done" compliance so agents don't ship untested code.
- Responding to user queries like "Why is this taking so long?" with a data-backed status report.
Known limitations
Requires Python 3.8+ installed on the local machine. It cannot detect loops occurring across multiple separate terminal sessions if the log is cleared between them.
Requires Python 3.8+ locally. Cannot track loops across fresh sessions if logs are cleared. Best results with Claude Code or Cursor; other agents require manual event logging.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 10 days ago
Requires