A local agent
const agent = api.agents.create({
runtime: "local",
machine: pc, // required
model: "gemini-3.5-flash", // required
mode: "ask",
tools: ["read", "list", "glob", "grep", "write", "edit", "bash"],
budget: 200,
memory: true,
onPermission: async ({ tool, category, args }) => "once",
onQuestion: async ({ question }) => answer(question),
});agent = api.agents.create(
runtime="local",
machine=pc, # required
model="gemini-3.5-flash", # required
mode="ask",
tools=["read", "list", "glob", "grep", "write", "edit", "bash"],
budget=200,
memory=True,
on_permission=lambda request: "once",
on_question=lambda request: answer(request["question"]),
)What is required
runtimestring"local" for the engine in your process. Absent builds the server-side agent.
machineConnectedStoragerequiredA computer, a phone, or a cloud workspace. See machine.
modelstringrequiredUnless you pass id, in which case it comes from the session.
Every option
| Option | Default | Page |
|---|---|---|
machine · workspace | — | machine |
model · fallbackModels · thinking · maxOutputTokens | — · [] · null · 16 000 | model and thinking |
tools · skills · subagents · mcp · agent | all · all · all · all · null | tools and library |
mode · onPermission · onQuestion · system | "ask" · — · — · "" | mode and permissions |
budget · maxSteps · contextTokens | null · 100 · 200 000 | budget and context |
media | {} | media |
memory · id · memories · checkpoints | false · — · true · true | memory and sessions |
files · shell · terminals · customTools | — | bridges |
What is refused, and when
| Code | When |
|---|---|
| machine_required | No machine, or one that is not a computer, a phone or a cloud workspace. |
| files_required | A phone or a cloud workspace without the six file operations. The message names the missing ones. |
| model_required | No model and no id. |
| invalid_mode | A mode outside the four. |
| unknown_tool | A tool name the engine does not know. The message lists the ones it does. |
| invalid_context | contextTokens that is not a whole number of at least 10 000. |
| invalid_shell | A shell without a run function. |
| invalid_custom_tool | A custom tool with no description, no run, a reserved name, or a category outside the four. |
| invalid_media | A media key that is not image, video, voice or music. |
| invalid_agent | An agent name that is not a library name. |
| invalid_session_id | An id that is not a session identifier. |
| workspace_not_allowed | A workspace other than the SDK's own folder. |
All of them throw at creation, not at run time
That is deliberate: a misconfigured agent should fail on the line that configures it. The one exception is contextTokens being larger than the model's window, which needs the catalogue and therefore surfaces on the first run.