# `A2UIAgent.RequestProcessor`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_agent/lib/a2ui_agent/request_processor.ex#L1)

Everything an agent needs to answer one request: the negotiated
catalogs, the inference format bound to them, its prompt snippet and
its parsers.

A processor is normally created by `A2UIAgent.Generator.create_processor/3`
from the renderer's capabilities.

    {:ok, processor} = A2UIAgent.RequestProcessor.new(catalogs, examples: [turn])
    {:ok, prompt} = A2UIAgent.RequestProcessor.prompt(processor)
    {:ok, parts} = A2UIAgent.RequestProcessor.parse_response(processor, model_output)

# `t`
*since 0.1.0* 

```elixir
@type t() :: %A2UIAgent.RequestProcessor{
  catalogs: [A2UICore.Catalog.t()],
  examples: [[map()]] | nil,
  format: struct()
}
```

# `active_catalogs`
*since 0.1.0* 

```elixir
@spec active_catalogs(t()) :: [A2UICore.Catalog.t()]
```

The active catalogs, in the renderer's order of preference.

# `new`
*since 0.1.0* 

```elixir
@spec new([A2UICore.Catalog.t()], keyword()) ::
  {:ok, t()} | {:error, A2UICore.Error.t()}
```

Creates a processor over the active `catalogs`.

Options: `:examples` — few-shot example turns, each checked with
`A2UIAgent.PayloadValidator` against the catalogs; `:format` — the
`t:A2UIAgent.Format.spec/0` (`A2UIAgent.DirectJson` by default).

# `parse_response`
*since 0.1.0* 

```elixir
@spec parse_response(t(), String.t(), keyword()) ::
  {:ok, [A2UIAgent.DirectJson.Parser.part()]} | {:error, A2UICore.Error.t()}
```

Parses and validates a complete model response with a fresh parser.
Option: `:wrapped` (default `true`).

# `parser`
*since 0.1.0* 

```elixir
@spec parser(t()) :: struct()
```

A fresh parser bound to the active catalogs.

# `prompt`
*since 0.1.0* 

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

The format's system prompt snippet.

---

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