# Parallelism

Canonical URL: https://developers.iagenify.com/sdk/agent/parallelism/
Language: en

Calls in one turn run together only when every one of them is a read or a subagent. Anything that could ask the user runs one at a time.

Status: read and task only · all-or-nothing per turn · subagents fan out

The rule is deliberately blunt: the engine looks at the [category](/sdk/agent/permissions/categories) of every call in the turn, and runs them in parallel only if **all** of them are `read` or `task`. One write in the batch and the whole turn goes sequential.

```javascript
// Parallel: three reads in one turn
read { path: "a.md" }   glob { pattern: "**/*.ts" }   grep { pattern: "TODO" }

// Sequential: the write makes the whole turn sequential
read { path: "a.md" }   write { path: "b.md", content: "…" }
```

## Why it is all-or-nothing {#why}

> **A permission prompt cannot be raced**
>
> If two calls needing approval ran at once, the user would face two prompts for actions whose order is undefined — and approving one would mean approving a state that the other is concurrently changing. Running them in order makes each prompt describe a situation that is actually true.

It also keeps the failure story simple: in a sequential turn, a call that fails is followed by calls that can see it failed.

## Subagents are where it pays {#subagents}

`task` is in the parallel set, so several subagents asked for in the same turn genuinely run at the same time, each with its own context. That is the one place where a long job gets meaningfully shorter.

```javascript
// The model asks for three in one turn — all three run at once
task { agent: "explore", description: "Map the data layer" }
task { agent: "explore", description: "Map the API routes" }
task { agent: "explore", description: "Find every TODO older than a year" }
```

Their turns are added to the parent's `usage` as they happen, so the shared [budget](/sdk/agent/budget) bites on all of them together. Their events reach your `onEvent` carrying `parentId`, and their identifiers are prefixed with the task's.

## A sequential turn checks for stop between calls {#stopped}

Each call in a sequential batch is preceded by the stop check, so `stop()` takes effect within the turn. A parallel batch is already in flight and finishes.

## The model is told to batch {#encourage}

The [system prompt](/sdk/agent/system-prompt) names the forms that exist — `read { paths }`, `bash { commands }`, independent tools in one turn — because a model does not produce them on its own. Each tool call costs a whole turn, so batching is the single biggest lever on what a run costs.

- [task](/sdk/agent/tools/task): The subagent tool.
- [Categories](/sdk/agent/permissions/categories): What makes a call a read.
- [The loop](/sdk/agent/loop): What one step is, and what ends it.

```python
# The Python engine runs the calls of one turn in order, one after the other:
#   read {"path": "a.md"}   glob {"pattern": "**/*.ts"}   grep {"pattern": "TODO"}

# A write in the same turn simply runs at its place in that order
#   read {"path": "a.md"}   write {"path": "b.md", "content": "…"}
```

```python
# The model may ask for several subagents in one turn; Python runs them one after the other
#   task {"agent": "explore", "description": "Map the data layer"}
#   task {"agent": "explore", "description": "Map the API routes"}
#   task {"agent": "explore", "description": "Find every TODO older than a year"}
```
