Documentation Home/Heuristics & Safety

Circuit Breaker Heuristics & Mathematical Equations

Deep dive into the 5 core safety algorithms that evaluate agent tool executions in sub-millisecond real time.

1Sliding-Window Repeat Call Interceptor (`maxRepeatCalls`)

Detects when an agent repeatedly invokes a tool using identical input payloads (SHA-256 canonical hash equality).

Count = sum(1 for t in recentCalls where SHA256(t.args) == SHA256(current.args))
If Count >= maxRepeatCalls (default 5) -> TRIP FUSE

2Dollar Cost Ceiling & Dynamic Progress Headroom (`maxCostDollar`)

Enforces a strict dollar limit on token expenditure per agent run while granting a 25% headroom bonus if active non-repetitive state progress is verified.

IsProgress = unique_count(recent_state_hashes[-3:]) == 3
EffectiveCap = IsProgress ? (maxCostDollar * 1.25) : maxCostDollar
If cumulativeCost >= EffectiveCap -> TRIP FUSE

3Recursion & Sub-Agent Call Depth Limiter (`maxDepth`)

Prevents stack overflow and runaway sub-agent spawns by capping maximum call graph depth (default 15 steps).

4No-Progress Turn Output State Hash Shield (`maxNoProgressTurns`)

Calculates SHA-256 hashes of tool execution turn outputs. Trips when N consecutive turns yield 100% identical outputs without state progress.

5Adaptive Recovery & Cheaper Model Fallback

Upon detecting a soft hallucination warning, Moven dynamically routes execution to a cheaper fallback model (`gpt-4o-mini`, `gemini-2.5-flash-lite`, etc.) and automatically restores the primary model after 3 clean turns.