# `Agentic.CircuitBreaker`

Per-tool circuit breaker for agent tool execution.

Tracks consecutive failures per tool name. After a configurable threshold
(default 3), the tool is marked as "open" and calls are rejected instantly
for a cooldown period (default 5 minutes).

State transitions:
  :closed (normal) -> 3 consecutive failures -> :open (rejecting)
  :open -> cooldown expires -> :half_open (testing)
  :half_open -> success -> :closed
  :half_open -> failure -> :open

Uses ETS for lock-free reads on the hot path. No GenServer needed.

# `state`

```elixir
@type state() :: :closed | :open | :half_open
```

# `check`

```elixir
@spec check(String.t()) :: :ok | {:error, :circuit_open}
```

Check if a tool is available (circuit closed or half-open).

# `get_state`

```elixir
@spec get_state(String.t()) :: state()
```

Get the current state of a tool's circuit breaker.

# `init`

Initialize the ETS table. Call once at app startup.

# `record_failure`

```elixir
@spec record_failure(String.t()) :: :ok
```

Record a failed tool execution. May trip the circuit.

# `record_success`

```elixir
@spec record_success(String.t()) :: :ok
```

Record a successful tool execution. Resets failure count.

# `reset`

```elixir
@spec reset(String.t()) :: :ok
```

Reset a specific tool's circuit breaker.

# `reset_all`

```elixir
@spec reset_all() :: :ok
```

Reset all circuit breakers.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
