# Fatto

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

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

La run termina. Porta esattamente o que run() restituisce — il medesimo oggetto, consegnato al callback in lugar del caller.

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

## Campos {#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 |  | L'ultimo testo il model scrit. Non necessariamente una risposta — vee `stopReason`. |
| `todos` | array |  | Il plan tals cum terminât. |
| `usage` | object |  | `{ credits, turns, toolCalls }` — tutto il run, i subagenti inclusi. |
| `stopReason` | string |  | `end_turn` · `stopped` · `max_steps` · `budget`. |
| `model` | string |  | Modele del agente. Per quel modele servit un virat dato, legga i [turn](/pt/sdk/agent/events/turn)events. |

## Ler stopReason prima di usar text {#reason}

> **max_steps e budgete lasci un pensiero inacabat**
>
> La run termina in cui era, quindi il testo è quel che il modello scrit ultima — possibly mid-plan. Solo end_turn significa «che ha finito di dire quello che ha dicit».

## Un subagente non ti raggiunge mai {#children}

Se lancia quando inoltra i succedanies di un bambino - un child finishing non è il final de run, e un'interface di ascolte per `done` termina prematuramente. I suoi cifre arrivano invece sul `task` call 's `tool_end`.

## Ambas le formules {#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
```

## l'ususus conta tutto {#usage}

Gira, utensili pagati, resumes de compactazion, e tutto ciò che ogni subagente ha fatto — il medesimo total del budget è stato contro comprobat.

- [O ciclo](/pt/sdk/agent/loop): Quando in un pas cada uno è emitat.
- [Orçamento](/pt/sdk/agent/budget): L'uso del tectus è misurat contro.

```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
```
