idstring|nullThe session identifier, set at creation when memory is on. null otherwise.
modelstringThe agent's model. For which model served a turn, read the turn events.
modestringThe mode in force. Changed with setMode().
titlestringTaken from the first message of a session.
usageobject{ credits, turns, toolCalls } — reset at the start of each run, subagents included.
contextobject{ tokens, limit, window, cachedTokens, cleared, parts }.
todosarrayThe current plan.
toolNamesstring[]The tools this agent was given, custom ones included.
libraryobject{ skills, subagents } — what the last run loaded.
libraryStatusobjectWhy a library is empty, when it is.
mcpServersarrayThe connected servers this run may use.
machine · files · shellobjectWhat it was given.
What changes during a run
const running = agent.run({ message: "…" });
const timer = setInterval(() => {
console.log(agent.usage.credits, "credits ·", agent.context.tokens, "tokens");
}, 1000);
await running;
clearInterval(timer);import threading
done = threading.Event()
def watch():
while not done.wait(1):
print(agent.usage["credits"], "credits ·", agent.context["tokens"], "tokens")
threading.Thread(target=watch, daemon=True).start()
agent.run(message="…")
done.set()usage, context, todos and library are all updated as the loop goes. Events are the better channel — they carry the same numbers at the moment they change — but polling works.
usage is per run
It is not a running total for the agent object. Keep your own sum across runs if you need the conversation's whole cost.
context, field by field
| Field | Is |
|---|---|
tokens | The last turn's size, as the provider measured it |
limit | The limit in force |
window | The model's own window, or null if the catalogue could not be read |
cachedTokens | What the provider served from cache |
cleared | How many tool results have been emptied |
parts | { system, tools, memory, messages } |
toolNames is what was selected, not what is declared
A tool that cannot run on this machine — bash with no shell on a phone — is already out of it. skill and task appear only once a library has something in it, so they are not in this list before the first run.