# tool_start

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

`{ type: "tool_start", id, tool, category, args }`

工具即将运行, 工具将使用它将运行的参数。 它会在任何许可批准后到达, 所以看到它就意味着电话正在响起。

Status: after the permission · args are final · paired with tool_end

## 字段 {#fields}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | 电话识别码 `tool_end` 携带相同的。 |
| `tool` | string |  | 工具的名字。 |
| `category` | string |  | 其 其 其 其 [类别](/zh/sdk/agent/permissions/categories) ——根据其中六个理由计算。 |
| `args` | object |  | 确切地说,它将运行。 |

## 平平 {#pairing}

```javascript
const started = new Map();

onEvent: (e) => {
  if (e.type === "tool_start") started.set(e.id, { tool: e.tool, at: Date.now(), args: e.args });
  if (e.type === "tool_end")   {
    const call = started.get(e.id);
    console.log(call.tool, e.ok ? "ok" : "failed", e.durationMs, "ms");
    started.delete(e.id);
  }
};
```

> **并非每个 tool_end 具有 a 的 tool_start**
>
> 拒绝的呼叫和呼叫未知工具仅发出 tool_end。通过 id 来对准和容忍一个没有开始的结束,或者一个摇晃的入口将永远坐在你的地图上。

## 几个可以同时打开 {#parallel}

转而每个呼唤都响起 `read` 或 a `task`引擎一起运行,这样你可以看到几个 `tool_start` 第一个 `tool_end`,结束以完成顺序而不是呼叫顺序到达。 `id` 是什么使这无害。

## 参数是显示 {#args}

`args.path`, `args.command`, `args.query`, `args.pattern`, `args.key` ——一个有意义的字符串是界面在工具名称旁边显示的。会话记录保持与短 *目标目标目标*.

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

- [tool_end](/zh/sdk/agent/events/tool-end): 是什么来的。
- [许可权限](/zh/sdk/agent/events/permission): 这件事之前发生了什么

```python
import time

started = {}

def on_event(event):
    if event["type"] == "tool_start":
        started[event["id"]] = {"tool": event["tool"], "at": time.monotonic(), "args": event["args"]}
    if event["type"] == "tool_end":
        call = started.pop(event["id"])
        print(call["tool"], "ok" if event["ok"] else "failed", round((time.monotonic() - call["at"]) * 1000), "ms")
```
