事件

已完成完成完成完成完成

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

运行结束。 它会包含运行返回的确切内容—— 同一对象, 发往回回调而不是呼叫者 。

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.

字段

{
  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

模型写的最后文本。 不一定是答案——见 stopReason.

todosarray

计划完成后就完成了

usageobject

{ credits, turns, toolCalls } - 整个运行,包括分剂。

stopReasonstring

end_turn · stopped · max_steps · budget.

modelstring

代理商的模型。 对于哪个模型为特定转弯服务, 请读 转转 活动。

使用文本前读取停止站

max_steps 预算和预算留下未完成的念头

运行结束, 其原本, 所以文本是任何模式 上写的—— 可能是中计划。 end_turn 意思是说完要说的话了

分剂的完成 从来没有达到你

儿童在儿童事件发生时即会丢弃,儿童完成不是完成,而是监听儿童活动的一个界面。 done 其数字将更早地公布在 task 调打 tool_end.

两种形式

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

使用时计算一切

转手、付费工具、压缩摘要和每个子剂所做的一切——预算总额也相同。