# `Alloy.Session`
[🔗](https://github.com/alloy-ex/alloy/blob/v0.12.4/lib/alloy/session.ex#L1)

Serializable session container.

> #### Moved to `alloy_agent` {: .warning}
>
> This struct has moved to `AlloyAgent.Session` in the
> [`alloy_agent`](https://hex.pm/packages/alloy_agent) package. This
> copy will be removed in Alloy 0.13.0. Migrate by replacing
> `%Alloy.Session{}` with `%AlloyAgent.Session{}` and
> `Alloy.Session.new/1` with `AlloyAgent.Session.new/1`.

Wraps the conversation state in a format that can be serialized
to JSON, stored in a database, or passed between processes.
No database required — sessions are plain structs.

# `t`

```elixir
@type t() :: %Alloy.Session{
  created_at: DateTime.t(),
  id: String.t(),
  messages: [Alloy.Message.t()],
  metadata: map(),
  updated_at: DateTime.t(),
  usage: Alloy.Usage.t()
}
```

# `new`

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

Creates a new session with a generated ID.

# `update_from_result`

```elixir
@spec update_from_result(t(), map()) :: t()
```

Updates a session with results from an agent run.

---

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