Table of Contents

Namespace JD.AI.Core.Safety

Classes

CircuitBreaker

Adaptive circuit breaker that wraps ToolLoopDetector to manage open/closed/half-open state transitions for tool invocations.

State machine: Closed → (hard-stop detected) → Open → (cooldown expires) → HalfOpen → (probe succeeds) → Closed.

CircuitBreakerResult

Result of a circuit breaker evaluation.

LoopDetectionResult

Result of a loop detection check.

ToolLoopDetector

Detects repetitive tool invocation patterns that indicate no-progress loops. Tracks a rolling window of recent calls and identifies:

  • Same-tool/same-args repetitions (stuck loops).
  • Ping-pong patterns between two tools/agents.
  • High-frequency bursts of any single tool.

Thread-safe — designed to be shared across a session.

Enums

CircuitAction

What the circuit breaker recommends for the current invocation.

CircuitState

Circuit breaker state machine states.

LoopDecision

What the detector recommends.

LoopType

Classification of the loop pattern detected.