# `Octoroom.Agent.Pipeline.Spec`
[🔗](https://github.com/samrat/octoroom/blob/v0.1.0/agents/lib/octoroom/agent/pipeline/spec.ex#L1)

Builds a pipeline spec with `|>`:

    import Octoroom.Agent.Pipeline.Spec

    processor(:vad, Octoroom.Agent.VAD.Silero)
    |> processor(:turns, MyApp.Turns, threshold: 0.5)
    |> processor(:llm, MyApp.LLM, model: "google:gemini-3.5-flash")

A spec is a plain value: a chain of named stages. The editing helpers
(`insert_after/3`, `insert_before/3`, `replace/3`, `remove/2`) find stages
by name, so a default spec can be changed without rewriting it.

A stage's name defaults to its module. Names must be unique.

# `name`

```elixir
@type name() :: atom()
```

# `t`

```elixir
@type t() :: %Octoroom.Agent.Pipeline.Spec{
  stages: [
    %Octoroom.Agent.Pipeline.Spec.Stage{
      module: term(),
      name: term(),
      opts: term()
    }
  ]
}
```

# `default`

The usual pipeline of an agent, in two parts: `{front_end, back_end}`.
Each input runs its own front end, and their turns go into one back end:

    front: vad -> stt -> turns
    back:  context -> llm -> tools -> chunker -> tts -> collector

It picks no provider and no model: `:stt`, `:llm` and `:tts` are needed,
each naming both. Options are their stage's, passed on as they are:

  * `:stt` - `Octoroom.Agent.Processors.STT`'s
  * `:llm` - `Octoroom.Agent.Processors.LLM`'s
  * `:tts` - `Octoroom.Agent.Processors.TTS`'s
  * `:vad` - `Octoroom.Agent.Processors.VAD`'s (the local Silero model).
    `false` leaves the VAD out: turn taking and barge-in fall back to the
    STT provider.
  * `:preemptive` - boolean forwarded to `Octoroom.Agent.Processors.STTTurns`
    to enable or disable preemptive LLM generation while STT finalizes
    (defaults to `true` when VAD is enabled, `false` when `vad: false`).

`:stt`, `:llm` and `:tts` also take just a `"provider:model"` string (or
`model: "provider:model"` alongside extra stage options).

    Spec.default(
      stt: "soniox:stt-rt-v6",
      llm: "google:gemini-3.5-flash",
      tts: [provider: :assembly_ai, model: "assemblyai-tts-1", voice: "aai-titus"]
    )

With `stt: false` (half-cascaded) the LLM hears each turn as audio, so it
must be a Gemini model, the VAD can't be left out, and `:transcriber`
(`Octoroom.Agent.Processors.Transcriber`'s options) names the model that
writes each turn down afterwards:

    front: vad -> turns (AudioTurns, Smart Turn)
    back:  transcriber -> context -> llm -> tools -> chunker -> tts -> collector

The front end's turn stage doesn't interrupt; the agent decides who may.
Change either part with the editing helpers.

# `gemini_live`

The pipeline of a Gemini Live agent: no front end (the agent mixes its
inputs) and one `:gemini` stage, `Octoroom.Agent.Processors.GeminiLive`,
which takes `opts`: `:model` (needed), `:voice`, `:api_key`,
`:context_window_compression` (`false` or `[trigger_tokens: ..., target_tokens: ...]`),
`:input_audio_transcription`, `:output_audio_transcription`, and
`:response_modalities`.

    Spec.gemini_live(
      model: "gemini-3.8-live",
      voice: "Puck",
      context_window_compression: [trigger_tokens: 24_000, target_tokens: 12_000]
    )

# `insert_after`

Inserts the stages of `insert` right after the stage `name`.

# `insert_before`

Inserts the stages of `insert` right before the stage `name`.

# `names`

Names of the stages, in order.

# `new`

An empty spec.

# `openai_live`

The pipeline of an OpenAI Live agent: no front end (the agent mixes its
inputs) and one `:openai` stage, `Octoroom.Agent.Processors.OpenAILive`,
which takes `opts`: `:model` (needed, such as `"gpt-live-1.1"`), `:voice`
(default `"marin"`), `:api_key` (default `OPENAI_API_KEY`), `:transport`
(`:webrtc`, the default, or `:websocket`), `:sample_rate` (`24_000` default,
or `16_000`; WebSocket only), `:delegation` (`:client`,
`[model: "...", ...]`, or a delegation map), `:idle_timeout_s` (`5..60`
seconds before standby, or `nil`; WebRTC only), `:wake_policy` (`:speech` or
`[type: :speech, vad_threshold: 0.5]`; WebRTC only), and `:initial_items`.

    Spec.openai_live(
      model: "gpt-live-1.1",
      voice: "marin",
      delegation: [model: "gpt-5.4-mini"],
      idle_timeout_s: 15,
      wake_policy: [type: :speech, vad_threshold: 0.5]
    )

# `opts`

The options of the stage named `name`, or nil when there's none.

# `processor`

Adds a stage to the end of a spec.

Accepts, optionally after a spec to pipe into: `module`, `name, module`,
`module, opts`, or `name, module, opts`.

# `processor`

# `processor`

# `processor`

# `remove`

Removes the stage `name`.

# `replace`

Replaces the stage `name` with the stages of `replacement`.

# `validate`

Checks that the spec has at least one stage, that names are unique, and
that every module implements `Octoroom.Agent.Processor`.

---

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