# Options · mode and permissions

Canonical URL: https://developers.iagenify.com/sdk/ref/agents/options/mode/
Language: en

`mode · onPermission · onQuestion · system`

What is allowed without asking, what happens when something must be asked, and what you add to the agent's instructions.

Status: ask by default · no callback means refused · system adds

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `mode` | string | "ask" | `ask` · `auto` · `plan` · `full`. |
| `onPermission` | function |  | `({ id, tool, category, args, mode }) => "once" \| "always" \| "deny"`. |
| `onQuestion` | function |  | `({ id, question, options }) => string`. Without it there is no `ask_user` tool. |
| `system` | string | "" | Added to the system prompt. It does not replace it. |

```javascript
api.agents.create({
  runtime: "local", machine: pc, model,
  mode: "auto",
  system: "This repository is a Next.js app. Never edit anything under generated/.",
  onPermission: async ({ category, args }) => {
    if (category !== "exec") return "deny";
    return /^npm (test|run build)$/.test(args.command) ? "always" : "deny";
  },
  onQuestion: async ({ question, options }) => askThePerson(question, options),
});
```

## Without onPermission it can only read {#no-callback}

> **Everything that would be asked is refused**
>
> The refusal says so — « needs the user's approval and no one can approve it » — and goes back to the model, which adapts. An agent with no callback is close to read-only whatever its mode, including full access.

## The mode changes mid-run {#changing}

```javascript
agent.setMode("auto");     // takes effect on the next tool call, subagents included
```

## system adds, nothing replaces {#system-adds}

It is appended after the engine's own instructions. There is no option that replaces the prompt, because most of it describes capabilities that genuinely exist — removing it would make the model wrong rather than free.

For instructions that should apply to every run on a workspace, a file is better: `IAGENIFY.md` in the workspace is read into the prompt, and a person can see it.

## Subagents inherit both callbacks {#inherited}

A delegate's tools reach your callback with the parent's mode. Delegating is not a way around a permission — which is exactly why `task` itself is free.

- [Modes](/sdk/agent/modes): The four.
- [Permissions](/sdk/agent/permissions): The callback in full.
- [System prompt](/sdk/agent/system-prompt): What you are adding to.

```python
import re

def on_permission(request):
    if request["category"] != "exec":
        return "deny"
    return "always" if re.fullmatch(r"npm (test|run build)", request["args"].get("command", "")) else "deny"

api.agents.create(
    runtime="local", machine=pc, model=model,
    mode="auto",
    system="This repository is a Next.js app. Never edit anything under generated/.",
    on_permission=on_permission,
    on_question=lambda request: ask_the_person(request["question"], request["options"]),
)
```

```python
agent.set_mode("auto")   # takes effect on the next tool call
```
