Fields
{
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"
}{
"type": "done",
"todos": [{"content": "Check the figures", "status": "completed"}],
"usage": {"credits": 31, "turns": 6, "toolCalls": 9},
"stopReason": "end_turn",
}textstringThe last text the model wrote. Not necessarily an answer — see stopReason.
todosarrayThe plan as it finished.
usageobject{ credits, turns, toolCalls } — the whole run, subagents included.
stopReasonstringend_turn · stopped · max_steps · budget.
modelstringThe agent's model. For which model served a given turn, read the turn events.
Read stopReason before using text
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
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
const result = await agent.run({
inputs: "…",
onEvent: (e) => { if (e.type === "done") render(e); }, // for the interface
});
console.log(result.stopReason); // the same objectresult = 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 addedusage counts everything
Turns, paid tools, compaction summaries, and everything every subagent did — the same total the budget was checked against.