# Class LittleGhost::RunResult

Documentation version: Edge

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

RunResult gives callers one final view of an Assembly invocation. It includes
the response, usage, updated conversation, state, coordination steps, and any
validated structured value.

Use #output when the caller should accept either structured or textual agents.
It returns the validated structured value when present and #text otherwise.

## Inheritance

`LittleGhost::RunResult < Data`

## Attributes

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

The final assistant Message, or `nil` when no message was produced.

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

The complete, updated conversation.

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

The application state at the end of the invocation.

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

Immutable Assembly::Step records for composite invocations.

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

The normalized reason the terminal model stream stopped.

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

The validated StructuredResult, or `nil` for a textual result.

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

The Usage accumulated across this invocation.

## Class methods

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

```ruby
new(message:, stop_reason:, usage:, messages:, state:,
    structured_result: nil, steps: []) -> RunResult
```

Creates the terminal value for one Assembly invocation.

## Instance methods

<a id="method-i-output"></a>
### `#output`

```ruby
#output()
```

Uses the structured value when present and otherwise #text.

<a id="method-i-structured-3F"></a>
### `#structured?`

```ruby
#structured?()
```

Indicates whether the invocation produced a validated structured result.

<a id="method-i-text"></a>
### `#text`

```ruby
#text()
```

Reads the final message text, or an empty string when no message exists.

<a id="method-i-trajectory"></a>
### `#trajectory`

```ruby
#trajectory()
```

Returns an Assembly::Trajectory for querying immutable coordination steps.
