const messages = await agent.getHistory();
for (const m of messages) {
console.log(m.role, m.parts[0].content);
for (const call of m.toolCalls || []) {
console.log(" ", call.name, call.target, call.ok ? "ok" : "failed", call.credits);
}
}messages = agent.get_history()
# [{"role", "content", "name", "toolCallId"}] — read from the local journal
for m in messages:
if m["role"] == "tool":
print(" ", m["name"], (m["content"] or "")[:60])
else:
print(m["role"], (m["content"] or "")[:80])rolestringuser or assistant. Tool messages are not in it.
partsarray[{ type: "text", content }] — the same shape a model session returns.
toolCallsarray{ id, name, target, ok, credits, durationMs } per call.
target is the short version of the arguments
The one meaningful string — a path, a pattern, a command, a query, a key. It is what an interface shows beside a tool's name, and what a session records.
Where it comes from
| Agent | Read from |
|---|---|
Without memory | What the object holds in memory |
With memory | The account |
Not from the account, and not from the object. The content of what a tool returned lives in the device journal and nowhere else — which is also why a session reopened elsewhere shows what was done without showing what was read.
It is for displaying, not for replaying
To continue a conversation, call run() on the agent — it already holds the state the model needs. This method is for showing a person what happened.