# text

Canonical URL: https://developers.iagenify.com/sdk/agent/events/text/
Language: en

`{ type: "text", text, final }`

The complete text of a turn, once. Its streaming companion is text_delta, which arrives piece by piece while the turn is still being written.

Status: one per turn with text · final says if it is the answer · text_delta streams

## Fields {#fields}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `text` | string |  | Everything the model wrote in this turn. |
| `final` | boolean |  | `true` when the turn asked for no tool — so this is the answer, and the loop is ending. |

## Most text is not the answer {#intermediate}

A model usually writes a sentence before calling a tool — « I will read the file first. » Those arrive with `final: false`. Only the last one, the turn with no tool call, is the answer.

```javascript
onEvent: (e) => {
  if (e.type !== "text") return;
  if (e.final) showAnswer(e.text);
  else showThinkingAloud(e.text);
}
```

## text_delta {#delta}

```javascript
{ type: "text_delta", delta: "I will read " }
```

One per piece as the provider produces it. It is the only event that arrives *during* a turn — everything else is emitted between two things.

> **Do not render both for the same turn**
>
> The deltas of a turn add up to exactly its text event. A display that appends the deltas and then appends the text shows every answer twice. Stream the deltas and use text to replace what you streamed, or ignore one of the two.

## A delegated run emits one final text {#delegation}

When a message starts with `@agent`, the named agent does the work and its report *is* the answer: one `text` with `final: true`, then `done`.

## The run returns the last one {#result}

`result.text` is the most recent text of the run — which on a run ending at a ceiling may not be `final`. Checking `stopReason` is what tells you whether it is an answer.

> **A subagent's events arrive here too**
>
> They carry parentId — the identifier of the task call that started them — and agent, its name. Their own id is prefixed with the task's, so two runs never collide. Test parentId before treating an event as the main run's.

- [done](/sdk/agent/events/done): What the run ends with.
- [Events](/sdk/agent/events): The whole list, and the order they arrive in.

```python
def on_event(event):
    if event["type"] == "text":
        show_answer(event["text"])
```

```python
# The Python engine emits each turn's text as one "text" event;
# to stream it token by token, call api.models.turn(on_text=...) directly.
{"type": "text", "text": "I will read the four notes…"}
```
