# `Sycophant.Context`

Public conversation handle for multi-turn LLM interactions.

Context is a builder for conversation state. It holds message history,
tools, streaming callbacks, and provider params. Model and response schema
are per-call concerns and live outside the context.

## Building a conversation

    ctx = Context.new()
          |> Context.add(Message.system("You are helpful."))
          |> Context.add(Message.user("Hello!"))

## Passing options

    opts = Context.to_opts(ctx)

# `t`

```elixir
@type t() :: %Sycophant.Context{
  messages: [Sycophant.Message.t()],
  params: map(),
  stream: (term() -&gt; term()) | {term(), (term(), term() -&gt; term())} | nil,
  tools: [Sycophant.Tool.t()]
}
```

# `add`

```elixir
@spec add(t(), Sycophant.Message.t() | [Sycophant.Message.t()]) :: t()
```

Appends one or more messages to the context.

# `from_map`

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

Deserializes a context from a plain map.

# `new`

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

Creates an empty context.

# `new`

```elixir
@spec new([Sycophant.Message.t()] | keyword()) :: t()
```

Creates a context from a message list or keyword opts.

# `new`

```elixir
@spec new(
  [Sycophant.Message.t()],
  keyword()
) :: t()
```

Creates a context from messages and keyword opts.

# `to_opts`

```elixir
@spec to_opts(t()) :: keyword()
```

Converts context fields into flat keyword opts for pipeline consumption.

---

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