Fields
idstringMatches the tool_start, when there was one.
toolstringThe tool's name.
okbooleantrue if it ran and returned. false if it threw, or was refused.
summarystringOne line, meant to be shown — « 3 files », « 2/5 done », or the refusal's reason.
metaobjectWhat the tool reports: a path, a count, credits, a subagent's figures.
durationMsintegerHow long it took. 0 on a call that never ran.
refusedbooleanPresent and true when a permission said no, or a mode refused it.
Three endings, two flags
| Ending | ok | refused | summary holds |
|---|---|---|---|
| It worked | true | absent | what it did |
| It threw | false | absent | the error message |
| It was refused | false | true | why — the mode, or « Refused by the user. » |
The result goes back to the model, which adapts. Showing it as an error makes a steered run look broken; showing it as a refusal is what it is.
meta, per tool
| Tool | meta carries |
|---|---|
read, write, move | the path it acted on |
todo_write | the whole list |
search, fetch, convert, media | credits |
task | the subagent's name, model, turns, tool calls, credits, stop reason and report |
skill | the skill's name and how many files it has |
meta.credits is the tool's own cost
It is already included in the next turn event's totalCredits. Show it per line if you like; do not add it to a running total you built from turns.
A task ends once, with its figures
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"])They carry parentId — the identifier of the task call that started them — and agent, its name. Their own id is prefixed with the task's, so two runs never collide. Test parentId before treating an event as the main run's.