# `Sycophant.Response`

The result of an LLM call.

Contains the generated text or structured object, any tool calls requested
by the model, token usage statistics, and an opaque `Context` that enables
conversation continuation.

## Continuing Conversations

Use `response.context` with `Context.add/2` to continue the conversation:

    {:ok, response} = Sycophant.generate_text("openai:gpt-4o-mini", messages)
    ctx = response.context |> Context.add(Message.user("Tell me more"))
    {:ok, follow_up} = Sycophant.generate_text("openai:gpt-4o-mini", ctx)

## Inspecting History

Use `messages/1` to retrieve the full conversation history:

    Response.messages(response)
    #=> [%Message{role: :user, ...}, %Message{role: :assistant, ...}]

## Serialization

Responses implement `Sycophant.Serializable` for JSON persistence:

    json = Sycophant.Serializable.Decoder.encode(response)
    restored = Sycophant.Serializable.Decoder.decode(json)

# `finish_reason`

```elixir
@type finish_reason() ::
  :stop
  | :tool_use
  | :max_tokens
  | :content_filter
  | :recitation
  | :error
  | :incomplete
  | :unknown
  | nil
```

# `t`

```elixir
@type t() :: %Sycophant.Response{
  context: Sycophant.Context.t(),
  finish_reason: finish_reason(),
  metadata: map(),
  model: String.t() | nil,
  object: map() | nil,
  raw: map() | nil,
  reasoning: Sycophant.Reasoning.t() | nil,
  text: String.t() | nil,
  tool_calls: [Sycophant.ToolCall.t()],
  usage: Sycophant.Usage.t() | nil
}
```

# `from_map`

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

Reconstructs a `Response` from a serialized map produced by `Sycophant.Serializable`.

# `messages`

```elixir
@spec messages(t()) :: [Sycophant.Message.t()]
```

Returns the full conversation message history from the response context.

The list includes all user, assistant, system, and tool result messages
exchanged during the conversation.

# `reasoning_text`

```elixir
@spec reasoning_text(t()) :: String.t() | nil
```

Returns the first reasoning content text, if present.

# `text`

```elixir
@spec text(t()) :: String.t() | nil
```

Returns the response text.

---

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