# tool_start

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

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

A tool is about to run, with the arguments it will run with. It arrives after any permission was granted — so seeing it means the call is happening.

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

## Fields {#fields}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | The call's identifier. `tool_end` carries the same one. |
| `tool` | string |  | The tool's name. |
| `category` | string |  | Its [category](/sdk/agent/permissions/categories) — computed from the arguments for six of them. |
| `args` | object |  | Exactly what it will run with. |

## Pairing it {#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);
  }
};
```

> **Not every tool_end has a tool_start**
>
> A refused call and a call to an unknown tool emit only tool_end. Pair by id and tolerate an end with no start, or a dangling entry will sit in your map forever.

## Several can be open at once {#parallel}

In a turn where every call is a `read` or a `task`, the engine runs them together — so you may see several `tool_start` before the first `tool_end`, and the ends arrive in completion order, not call order. Keying on `id` is what makes that harmless.

## The arguments are the display {#args}

`args.path`, `args.command`, `args.query`, `args.pattern`, `args.key` — the one meaningful string is what an interface shows beside the tool's name. The session record keeps the same idea as a short *target*.

> **A subagent's events arrive here too**
>
> 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.

- [tool_end](/sdk/agent/events/tool-end): What came of it.
- [permission](/sdk/agent/events/permission): What happens before this event.

```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")
```
