# Class LittleGhost::StreamEvent

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/StreamEvent.html

StreamEvent gives every provider and interface the same language for live
agent output. Consumers can handle text, reasoning, tools, usage, retries, and
completion without branching on a provider SDK.

Providers emit events such as `:message_start`,
`:text_delta`, `:reasoning_delta`,
`:tool_call_start`, `:tool_call_delta`,
`:tool_call_stop`, `:usage`, `:model_retry`,
and `:message_stop`. The terminal event carries a
[ModelResponse](ModelResponse.md) in
`data[:response]`. An `:agent_stream` event wraps a
copied, frozen Agent event with an
[AgentStreamSource](AgentStreamSource.md) when a Run
exposes nested work.

    event = LittleGhost::StreamEvent.build(:text_delta, text: "Hello")
    event.type        # => :text_delta
    event.data[:text] # => "Hello"

## Inheritance

`LittleGhost::StreamEvent < Data`

## Attributes

<a id="attribute-i-data"></a>
### `data` (R)

The frozen outer payload Hash. Nested values are retained and must not be
mutated by callers.

<a id="attribute-i-type"></a>
### `type` (R)

The event kind, such as `:text_delta`, `:usage`, or
`:message_stop`.

## Class methods

<a id="method-c-build"></a>
### `.build`

```ruby
build(type, **data) -> StreamEvent
```

Creates an event with a symbol `type` and frozen outer payload Hash.
