# `Spectre.Supervisor`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/otp/supervisor.ex#L1)

Dynamic supervisor for Spectre Sessions and Agent Instances.

Add it to your application supervision tree:

    children = [
      {Spectre.Supervisor, name: MyApp.SpectreSupervisor}
    ]

Then start a subject-scoped Agent Instance:

    {:ok, pid} =
      Spectre.Supervisor.summon(
        MyApp.SpectreSupervisor,
        MyApp.Agents.ProjectAgent,
        subject: account.id,
        opts: [model: &MyApp.LLM.complete/2]
      )

Calls without `:subject` retain the legacy conversation-scoped
`Spectre.Session` behaviour.

# `session_option`

```elixir
@type session_option() :: Spectre.Session.option()
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `dismiss`

```elixir
@spec dismiss(GenServer.server(), pid()) :: :ok | {:error, term()}
```

Stops a supervised Spectre session.

    :ok = Spectre.Supervisor.dismiss(MySupervisor, pid)

# `instance`

```elixir
@spec instance(
  GenServer.server(),
  module() | Spectre.AgentRef.t(),
  Spectre.Subject.t() | term(),
  keyword()
) :: DynamicSupervisor.on_start_child()
```

Starts or returns the unique Instance for `agent + subject`.

# `start_link`

```elixir
@spec start_link(keyword()) :: Supervisor.on_start()
```

Starts the dynamic supervisor for Spectre sessions.

    {:ok, pid} = Spectre.Supervisor.start_link(name: MyApp.SpectreSupervisor)

# `summon`

```elixir
@spec summon(GenServer.server(), module(), [
  session_option() | Spectre.Instance.option()
]) ::
  DynamicSupervisor.on_start_child()
```

Starts a supervised Spectre Instance or legacy Session under `supervisor`.

    {:ok, pid} = Spectre.Supervisor.summon(MySupervisor, MyAgent, subject: account.id)

---

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