Get an API key
api.agents

Options · mode and permissions

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.

ask by defaultno callback means refusedsystem adds
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

modestring"ask"

ask · auto · plan · full.

onPermissionfunction

({ id, tool, category, args, mode }) => "once" | "always" | "deny".

onQuestionfunction

({ id, question, options }) => string. Without it there is no ask_user tool.

systemstring""

Added to the system prompt. It does not replace it.

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),
});
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"]),
)

Without onPermission it can only read

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

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

system adds, nothing replaces

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

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.