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",
}textstringL'ultimo testo il model scrit. Non necessariamente una risposta — vee stopReason.
todosarrayIl plan tals cum terminât.
usageobject{ credits, turns, toolCalls } — tutto il run, i subagenti inclusi.
stopReasonstringend_turn · stopped · max_steps · budget.
modelstringModele del agente. Per quel modele servit un virat dato, legga i turnevents.
Ler stopReason prima di usar text
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 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 addedl'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.