# tool_end

Canonical URL: https://developers.iagenify.com/zh/sdk/agent/events/tool-end/
Language: zh

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

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

Status: ok tells you which · refused is not an error · meta.credits is per tool

## 字段 {#fields}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | 匹配 `tool_start`那时有 |
| `tool` | string |  | 工具的名字。 |
| `ok` | boolean |  | `true` 如果它跑回来的话 `false` 假若弃绝它,或被拒, |
| `summary` | string |  | 一条线,要显示——“3文件”,“2”/5 或拒绝的理由 |
| `meta` | object |  | 工具报告什么: 一条路径,一个计数, `credits`,一个子剂的数字。 |
| `durationMs` | integer |  | 花了多长时间 `0` 接到一个从未跑过的电话 |
| `refused` | boolean |  | 现现和 `true` 当一个许可被拒绝,或一个模式拒绝的时候, |

## 三尾两旗,三尾两旗 {#three-endings}

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

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

## 元, 每个工具 {#meta}

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

## meta.credits 工具本身的成本 {#credits}

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

## 任务结束一次,以数字结束 {#task}

```javascript
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})`);
}
```

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

- [tool_start](/zh/sdk/agent/events/tool-start): 另一半的对。
- [智能体工具](/zh/sdk/agent/tools): 每项工具的报告内容。

```python
# 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"])
```
