Eventos

Fatto

{ 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.

last eventsame as the returnchildren's done is dropped
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Campos

{
  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",
}
textstring

L'ultimo testo il model scrit. Non necessariamente una risposta — vee stopReason.

todosarray

Il plan tals cum terminât.

usageobject

{ credits, turns, toolCalls } — tutto il run, i subagenti inclusi.

stopReasonstring

end_turn · stopped · max_steps · budget.

modelstring

Modele del agente. Per quel modele servit un virat dato, legga i turnevents.

Ler stopReason prima di usar text

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

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

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

console.log(result.stopReason);                            // the same object
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

l'ususus conta tutto

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