Agent (server-side)

run()

agent.run({ inputs, outputs?, history?, onStep?, signal? }) → Promise<Result>

Streams a run from the platform: one callback per step, and the result when it ends.

POST /api/ai/agents/runserver-sent eventserrors keep their type
Using Python?

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

inputsarrayrequired

[{ type: "text", content }], images included. An empty array throws.

outputsarray

Overrides what the agent was created with, for this run.

historyarray

The conversation to send. Absent uses the agent's own; [] starts fresh.

onStepfunction

Called with each step as it happens.

signalAbortSignal

Cancels the request.

What a step carries

{
  index: 2,
  kind: "tool",
  tool: "search",
  input: "customer churn definition",
  reasoning: "I will look up how they define churn.",
  summary: "5 result(s)",
  error: "",
  credits: 7,
  durationMs: 1840,
  meta: { enginesUsed: [...], results: [...] }
}
{
    "index": 2,
    "kind": "tool",
    "tool": "search",
    "input": "customer churn definition",
    "reasoning": "I will look up how they define churn.",
    "summary": "5 result(s)",
    "error": "",
    "credits": 7,
    "durationMs": 1840,
    "meta": {"enginesUsed": [...], "results": [...]},
}

credits is the run's running total, not this step's. meta is whatever the tool reports — the pages it opened, the sources it found, the figures of a generation.

Three refusals arrive as a step's error

errorWhen
Unknown toolThe model named something you did not declare. The message lists what is available.
Missing argumentA tool that needs one was called without it.
Already doneThe same tool with the same argument, twice.
Refused: … credits neededThe declared cost would pass budget.

The run continues after each of them — a refusal is information the model can act on.

Errors keep their type through the stream

import { NotEnoughCredits, Unauthorized, IaGenifyError } from "iagenify";

try {
  await agent.run({ inputs });
} catch (err) {
  if (err instanceof NotEnoughCredits) { /* … */ }
}
from iagenify import IaGenifyError, NotEnoughCredits, Unauthorized

try:
    agent.run(inputs=inputs)
except NotEnoughCredits:
    pass  # …
A failure inside the stream is translated back

It travels as JSON, and is rebuilt into the same class the rest of the package throws — so instanceof works here as it does everywhere else, instead of giving you a bare Error you cannot tell from a network failure.

An unknown builtin is refused outright

A tool whose builtin the platform does not know fails the run rather than being dropped. A workflow quietly missing the tool it was built around is the kind of failure nobody ever diagnoses.

Local work pauses the run

When a step needs the caller's computer, the run asks and waits for your process to answer. Abandon the request and that step never completes.