# `MingaAgent.ModelSelection`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/model_selection.ex#L1)

Immutable authority for one executable native model selection.

Persisted values decode into `Stored`, which deliberately has no ReqLLM model.
A selection becomes active only after its exact route has been validated and
materialized into one inline `LLMDB.Model`.

# `capability`

```elixir
@type capability() :: MingaAgent.ModelSelection.Policy.capability()
```

# `credential_ref`

```elixir
@type credential_ref() ::
  MingaAgent.ModelSelection.Credential.ApiKey.t()
  | MingaAgent.ModelSelection.Credential.OAuth.t()
```

# `image_tool_result_delivery`

```elixir
@type image_tool_result_delivery() ::
  :supported | {:unsupported, :model_image_input | :tool_result_transport}
```

# `t`

```elixir
@type t() :: %MingaAgent.ModelSelection{
  backend_id: String.t(),
  backend_module: module(),
  credential: credential_ref(),
  evidence: MingaAgent.ModelSelection.Evidence.t(),
  policy: MingaAgent.ModelSelection.Policy.t(),
  request_model: LLMDB.Model.t(),
  route: MingaAgent.ModelSelection.Route.t()
}
```

# `build`

```elixir
@spec build(
  map(),
  MingaAgent.ModelSelection.Route.t(),
  credential_ref(),
  MingaAgent.ModelSelection.Policy.t(),
  MingaAgent.ModelSelection.Evidence.t()
) :: {:ok, t()} | {:error, term()}
```

Constructs the only valid form of a newly active selection.

# `credential_id`

```elixir
@spec credential_id(credential_ref()) :: String.t()
```

Returns a human-readable, secret-free credential identity.

# `decode`

```elixir
@spec decode(map()) :: {:ok, MingaAgent.ModelSelection.Stored.t()} | {:error, term()}
```

Decodes and validates persisted data without making it executable.

# `encode`

```elixir
@spec encode(t()) :: map()
```

Encodes an active selection without runtime modules, models, paths, or secrets.

# `id`

```elixir
@spec id(t() | MingaAgent.ModelSelection.Stored.t()) :: String.t()
```

Returns an opaque stable hash of the exact route and credential identity.

# `image_tool_result_delivery`

```elixir
@spec image_tool_result_delivery(t()) :: image_tool_result_delivery()
```

Composes image-input and tool-result transport support for the exact selection.

# `images?`

```elixir
@spec images?(t()) :: boolean()
```

Returns true only when image input is explicitly supported.

# `materialize`

```elixir
@spec materialize(MingaAgent.ModelSelection.Stored.t(), map()) ::
  {:ok, t()} | {:error, term()}
```

Materializes a decoded stored selection against its declared Minga backend.

# `tool_result_images?`

```elixir
@spec tool_result_images?(t()) :: boolean()
```

Returns true only when the exact route explicitly supports images in tool results.

# `tools?`

```elixir
@spec tools?(t()) :: boolean()
```

Returns true only when tool use is explicitly supported.

# `version`

```elixir
@spec version() :: pos_integer()
```

Returns the persistence codec version.

# `with_reasoning`

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

Changes reasoning effort while preserving the immutable executable route.

---

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