Loop Termination Architecture — Production Agent Circuit Breaker
SkillSkill
Runaway agent loops are not a prompt problem. They are an architecture problem. This is the fix.
About
Every runaway agent loop follows the same pattern: no budget, no diminishing-returns detector, no hard stop. The agent works until the session times out, the bill is enormous, and the output is worse than it would have been at iteration 2. This SKILL.md ends that.
⚡ What's Inside
-
BudgetTracker implementation Four fields: continuationCount, lastDeltaTokens, lastGlobalTurnTokens, startedAt. Initialized to zero, never reset mid-loop. These four numbers are everything the termination logic needs
-
5-condition termination sequence Evaluated in strict order on every iteration. Named subagent? Stop. Budget null or zero? Stop. Diminishing returns (continuationCount ≥ 3, delta < 500 tokens)? Stop. 90% budget consumed? Stop. Otherwise: continue and inject the nudge
-
The nudge injection template Exact text that keeps agents working instead of summarizing. The difference between an agent that restates what it did and one that keeps doing it
-
Diminishing returns detection The condition that catches a working agent that has quietly run out of meaningful progress, before it exhausts the entire budget producing noise
🏭 Proven in Production
The 90% budget threshold came from watching agents that used 100% produce nothing actionable in the final 10%. The diminishing returns detector came from loops that were technically progressing but producing duplicate work. Every condition in this file closed a real failure mode.
🆕 What's New in v1.1
- Loop completion logging format added
- Budget governor integration notes for multi-agent coordinator patterns
✅ Core Capabilities
- ✅ BudgetTracker struct — four fields, complete implementation spec
- ✅ 5-condition termination evaluator — deterministic, priority-ordered
- ✅ Diminishing returns detector — catches productive-looking loops that have gone flat
- ✅ Nudge injection template — keeps agents working, not summarizing
- ✅ 90% budget hard stop — eliminates the final-10% noise phase
- ✅ Loop completion log format — every run produces a termination receipt
Core Capabilities
- Hard stop threshold logic
- Exponential backoff sequences
- Consecutive failure circuit breaker
- Graceful degradation patterns
- BudgetTracker state management
- Diminishing returns detection
- Stop hook execution order
Customer ratings
0 reviews
No ratings yet
- 5 star0
- 4 star0
- 3 star0
- 2 star0
- 1 star0
No reviews yet. Be the first buyer to share feedback.
Version History
This skill is actively maintained.
April 3, 2026
v1.0: Production loop termination architecture.
One-time purchase
$19
By continuing, you agree to the Buyer Terms of Service.
Details
- Type
- Skill
- Category
- Engineering
- Price
- $19
- Version
- 1
- License
- One-time purchase
Works With
Works with OpenClaw, Claude Projects, Custom GPTs and other instruction-friendly AI tools.
Works great with
Personas that pair well with this skill.
Complete Agent Operations Pack — 10-Skill Production Architecture Suite
Bundle
Every production architecture your OpenClaw agent needs — 10 SKILL.md files across compaction, security, memory, coordination, parallelism, and cost. One install, no coverage gaps.
$149

CipherClaw — AI Security Architect
Persona
Your AI security architect for OpenClaw & Claude Code. OWASP · SOC 2 · HIPAA · GDPR · PCI DSS — without being asked.
$10
Cody
Persona
Ship code, not excuses. A production-ready coding agent that builds, debugs, and deploys.
$99