# Overview

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

A real agent loop, running inside your process. The server serves one thing — a model turn — and every tool executes where your code is.

Status: runtime: "local" · 36 tools · the loop is yours

`api.agents.create({ runtime: "local" })` does not start anything remote. It builds an object that, when you call `run()`, asks the model what to do, performs the tools itself, feeds the results back, and repeats until the model stops asking. That loop is the product.

## What follows from running it here {#consequences}

| Because the loop is local | You get |
| --- | --- |
| Tools execute in your process | An agent reads the disk it is on. Nothing is uploaded to be looked at. |
| Permission is a callback | Your code decides, per call, with the arguments in hand. |
| Credits are counted as they go | A budget can stop the run before the next call, not after the bill. |
| The history is yours | You can read it, cut it, summarise it, or throw it away. |
| Only the turn is remote | The one thing a server has to do is the only thing it does. |

## The smallest agent that works {#smallest}

```javascript
import { IaGenify } from "iagenify";

const api = new IaGenify({ apiKey: process.env.IAGENIFY_API_KEY });
const pc = await api.storage.get();

const agent = api.agents.create({
  runtime: "local",
  machine: pc,
  model: "gemini-3.5-flash",
  mode: "ask",
  onPermission: async ({ tool, category, args }) => {
    console.log("asking for", tool, category, args);
    return "once";                       // "once" | "always" | "deny"
  },
});

const result = await agent.run({
  inputs: "Read every markdown file in Notes and tell me what is unfinished.",
  onEvent: (event) => {
    if (event.type === "text") process.stdout.write(event.text);
  },
});

console.log(result.stopReason, result.usage);
```

## The pieces, and where each is documented {#pieces}

| Piece | Decides | Page |
| --- | --- | --- |
| `machine` | Where the tools run — a computer, a phone, a cloud workspace. | [Options · machine](/sdk/ref/agents/options/machine) |
| `mode` | What is allowed without asking. | [Modes](/sdk/agent/modes) |
| `onPermission` | What happens when something must be asked. | [Permissions](/sdk/agent/permissions) |
| `tools` | Which of the 35 the model is told about. | [Agent tools](/sdk/agent/tools) |
| `budget` · `maxSteps` | When the loop gives up. | [Budget](/sdk/agent/budget) |
| `memory` | Whether the conversation survives the process. | [Sessions](/sdk/agent/sessions) |
| `onEvent` | What you see while it works. | [Events](/sdk/agent/events) |

## There is a second, older agent {#server-side}

Without `runtime`, `create()` builds the [server-side agent](/sdk/ref/agent): the loop runs on the platform, the tools are the platform's, and your code receives steps. It is what a [workflow step](/sdk/workflows/steps/agent-run) uses, because a workflow has no process of yours to run in.

> **Prefer the local engine when you have a process**
>
> It has the larger tool set, the permission callback, checkpoints, skills and subagents. The server-side one exists for the case where nothing of yours is running.

## What a run costs {#cost}

One model turn per step, billed like any turn, plus whatever the paid tools spend — a search, a page capture, a generated image. `usage` carries the total, and every `turn` event carries the running count.

```javascript
result.usage;    // { credits: 31, turns: 6, toolCalls: 9 }
```

- [The loop](/sdk/agent/loop): What one step is, and what ends it.
- [Modes](/sdk/agent/modes): The four, and what each one opens.
- [LocalAgent](/sdk/ref/local-agent): Every property and method of the object.

```python
import os, sys
from iagenify import IaGenify

api = IaGenify(api_key=os.environ["IAGENIFY_API_KEY"])
pc = api.storage.get()

def on_permission(request):
    print("asking for", request["tool"], request["category"], request["args"])
    return "once"                         # "once" | "always" | "deny"

agent = api.agents.create(
    runtime="local",
    machine=pc,
    model="gemini-3.5-flash",
    mode="ask",
    on_permission=on_permission,
)

def on_event(event):
    if event["type"] == "text":
        sys.stdout.write(event["text"])

result = agent.run(
    inputs="Read every markdown file in Notes and tell me what is unfinished.",
    on_event=on_event,
)

print(result["stopReason"], result["usage"])
```

```python
result["usage"]   # {"credits": 31, "turns": 6, "toolCalls": 9}
```
