事件

tool_end

{ type: "tool_end", id, tool, ok, summary, meta, durationMs, refused? }

呼叫完成、 失败或被拒绝。 摘要是一行要显示的; 元是工具要您知道的, 包括成本 。

ok tells you whichrefused is not an errormeta.credits is per tool
Using Python?

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

字段

idstring

匹配 tool_start那时有

toolstring

工具的名字。

okboolean

true 如果它跑回来的话 false 假若弃绝它,或被拒,

summarystring

一条线,要显示——“3文件”,“2”/5 或拒绝的理由

metaobject

工具报告什么: 一条路径,一个计数, credits,一个子剂的数字。

durationMsinteger

花了多长时间 0 接到一个从未跑过的电话

refusedboolean

现现和 true 当一个许可被拒绝,或一个模式拒绝的时候,

三尾两旗,三尾两旗

结束好拒绝拒绝内有的 总计
成功了,它成功了,它成功了true缺缺和它所做的事
扔了,扔了false缺缺错误消息
拒绝申请被拒绝falsetrue为什么是模式,或“被用户拒绝”。
拒绝是正常的结果

结果可以追溯到模型, 模型会调整。 显示为错误会使一个引导运行的运行看起来破损; 显示为拒绝就是拒绝。

元, 每个工具

工具内元承承承
read, write, move其行动路线
todo_write整个列表
search, fetch, convert媒体credits
task子试剂的名称、型号、旋转、工具呼叫、信用、停止理由和报告
skill技能的名称和它有多少文件

meta.credits 工具本身的成本

下一份已纳入 turn 事件事件 totalCredits。如果您愿意,请按行显示;不要将它添加到从旋转中构建的运行总量中。

任务结束一次,以数字结束

if (e.type === "tool_end" && e.tool === "task") {
  const { agent, turns, toolCalls, credits, stopReason } = e.meta;
  console.log(`${agent}: ${turns} turns, ${toolCalls} calls, ${credits} credits (${stopReason})`);
}
# A subagent's report is the result of its "task" call; its own events carry parentAgent
def on_event(event):
    if event["type"] == "tool_end" and event["tool"] == "task":
        print("subagent finished:", event["summary"])
子智能体事件也会传递到这里

它们随身携带 palclId —— 启动它们的任务电话的识别符号 —— 以及代理、 其名称。 他们自己的代号与任务名称相加, 所以两个运行时不会相撞 。 在将事件作为主运行程序处理之前先测试 palId 。