# `Agentic.Strategy`

Behaviour for orchestration strategies.

A strategy controls how the agent loop runs: it can modify opts before
each run, decide whether to re-run, react to events, and contribute
telemetry tags.

## Callbacks

| Callback | When | Purpose |
|----------|------|---------|
| `init/1` | Before first run | Strategy-specific setup |
| `prepare_run/2` | Before each `Agentic.run` | Modify profile, mode, system prompt, etc. |
| `handle_result/3` | After each run completes | Decide: done, rerun, or record |
| `telemetry_tags/0` | In telemetry events | Strategy-specific dimensions |

# `ctx`

```elixir
@type ctx() :: Agentic.Loop.Context.t()
```

# `opts`

```elixir
@type opts() :: keyword()
```

# `state`

```elixir
@type state() :: term()
```

# `description`

```elixir
@callback description() :: String.t()
```

# `display_name`

```elixir
@callback display_name() :: String.t()
```

# `handle_result`

```elixir
@callback handle_result(
  result :: {:ok, map()} | {:error, term()},
  opts :: keyword(),
  state :: state()
) ::
  {:ok, new_state :: state()}
  | {:rerun, new_opts :: keyword(), new_state :: state()}
  | {:done, final_result :: map(), new_state :: state()}
  | {:error, term()}
```

# `id`

```elixir
@callback id() :: atom()
```

# `init`

```elixir
@callback init(opts :: keyword()) :: {:ok, state()} | {:error, term()}
```

# `prepare_run`

```elixir
@callback prepare_run(opts :: keyword(), state :: state()) ::
  {:ok, prepared_opts :: keyword(), new_state :: state()} | {:error, term()}
```

# `telemetry_tags`
*optional* 

```elixir
@callback telemetry_tags() :: [{atom(), term()}]
```

---

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