| Method | Does |
|---|---|
| run(options) | One exchange: your message in, the answer out. |
| stop() | Ends the current run. |
| setMode(mode) | Changes the mode, mid-run, subagents included. |
| compact() | Summarises the conversation now. |
| getHistory() | The conversation, in display shape. |
| checkpoints() | Where you can go back to. |
| rewind(n) | Goes back to a message. |
| destroy() | Removes the session. |
const agent = api.agents.create({ runtime: "local", machine: pc, model, memory: true });
const result = await agent.run({
message: "Read the notes and list what is unfinished.",
onEvent: (e) => { if (e.type === "text_delta") process.stdout.write(e.delta); },
});
console.log(agent.usage, agent.context.tokens, result.stopReason);agent = api.agents.create(runtime="local", machine=pc, model=model, memory=True)
result = agent.run(
message="Read the notes and list what is unfinished.",
on_event=lambda e: print(e["text"]) if e["type"] == "text" else None,
)
print(agent.usage, agent.context["tokens"], result["stopReason"])run() is one exchange, not one task
It takes your message, loops until the model stops asking for tools, and returns. Calling it again continues the same conversation — the object holds the history.
The object is reusable, and not concurrent
One run at a time
A second run() while one is in flight shares the same message list and the same usage counters. Await the first, or build a second agent.
You can read its state while it works
usage, context, todos, mode and messages are live. An interface can poll them, or listen to events, which is cheaper and more precise.