# done

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

`{ type: "done", text, todos, usage, stopReason, model }`

The run ended. It carries exactly what run() returns — the same object, delivered to the callback instead of to the caller.

Status: last event · same as the return · children's done is dropped

## Fields {#fields}

```javascript
{
  type: "done",
  text: "I read the four notes. Two are unfinished: …",
  todos: [{ content: "Check the figures", status: "completed" }],
  usage: { credits: 31, turns: 6, toolCalls: 9 },
  stopReason: "end_turn",
  model: "gemini-3.5-flash"
}
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `text` | string |  | The last text the model wrote. Not necessarily an answer — see `stopReason`. |
| `todos` | array |  | The plan as it finished. |
| `usage` | object |  | `{ credits, turns, toolCalls }` — the whole run, subagents included. |
| `stopReason` | string |  | `end_turn` · `stopped` · `max_steps` · `budget`. |
| `model` | string |  | The agent's model. For which model served a given turn, read the [turn](/sdk/agent/events/turn) events. |

## Read stopReason before using text {#reason}

> **max_steps and budget leave an unfinished thought**
>
> The run ends where it was, so text is whatever the model last wrote — possibly mid-plan. Only end_turn means « it finished saying what it had to say ».

## A subagent's done never reaches you {#children}

It is dropped when forwarding a child's events — a child finishing is not the run finishing, and an interface listening for `done` would end early. Its figures arrive instead on the `task` call's `tool_end`.

## Both forms {#both}

```javascript
const result = await agent.run({
  inputs: "…",
  onEvent: (e) => { if (e.type === "done") render(e); },   // for the interface
});

console.log(result.stopReason);                            // the same object
```

## usage counts everything {#usage}

Turns, paid tools, compaction summaries, and everything every subagent did — the same total the budget was checked against.

- [The loop](/sdk/agent/loop): Where in a step each one is emitted.
- [Budget](/sdk/agent/budget): The ceiling usage is measured against.

```python
{
    "type": "done",
    "todos": [{"content": "Check the figures", "status": "completed"}],
    "usage": {"credits": 31, "turns": 6, "toolCalls": 9},
    "stopReason": "end_turn",
}
```

```python
result = agent.run(
    inputs="…",
    on_event=lambda e: render(e) if e["type"] == "done" else None,   # for the interface
)

print(result["stopReason"])   # the same stop reason, with text and model added
```
