# `Raxol.AgentClientProtocol.Schema.AgentTypes.StopReason`
[🔗](https://github.com/DROOdotFOO/raxol-agent/blob/raxol_agent_client_protocol-v0.1.0/packages/raxol_agent_client_protocol/lib/raxol/agent_client_protocol/schema/agent_types.ex#L1251)

Why a `session/prompt` turn ended.

Ported from the MIT `f1729/agent_client_protocol` (c) 2025 f1729; see NOTICE.md.

# `t`

```elixir
@type t() :: :end_turn | :max_tokens | :max_turn_requests | :refusal | :cancelled
```

# `from_json`

```elixir
@spec from_json(term()) :: {:ok, t()} | {:error, {:invalid_stop_reason, term()}}
```

Total: unrecognized stop reason strings return
`{:error, {:invalid_stop_reason, _}}` instead of raising
(upstream's version had no catch-all clause here).

# `to_json`

```elixir
@spec to_json(t()) :: String.t()
```

---

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