claude-flow
Version:
Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration
31 lines • 1.53 kB
TypeScript
/**
* Tool-loop circuit breaker (hermes-agent tool_guardrails pattern).
*
* Detects an agent stuck repeating the same failing command — a real silent
* failure mode where a loop burns turns with no signal. This is ORTHOGONAL to
* the security `tool-output-guardrail` (which detects indirect prompt injection
* in tool *output*); this one watches the agent's own *call* pattern.
*
* Design (deterministic, in-memory, bounded):
* - `recordCommandOutcome` (called by post-command) appends (command, success)
* to a small ring buffer.
* - `checkCommandLoop` (called by pre-command) returns a verdict for a command
* about to run, based on its recent consecutive-failure streak.
* - Verdict is advisory by default (`warn`); callers decide whether to block.
* An orchestration layer that doesn't own the UI should not hard-stop.
*/
export type LoopVerdict = 'allow' | 'warn' | 'block';
/** Record a command's outcome. Called from the post-command hook. */
export declare function recordCommandOutcome(command: string, success: boolean): void;
/**
* Verdict for a command about to execute. Called from the pre-command hook.
* Returns the verdict, the failure streak, and a recovery hint when looping.
*/
export declare function checkCommandLoop(command: string): {
verdict: LoopVerdict;
consecutiveFailures: number;
hint?: string;
};
/** Test/reset helper — clears the in-memory history. */
export declare function _resetLoopHistory(): void;
//# sourceMappingURL=tool-loop-guardrail.d.ts.map