LocalAgent

getHistory()

agent.getHistory() → Promise<Message[]>

The conversation in display shape: user and assistant messages, each with the tools it called and how they went.

freesame shape as a model sessionsource depends on memory
Using Python?

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

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])
rolestring

user 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

AgentRead from
Without memoryWhat the object holds in memory
With memoryThe account
Tool results are never in it

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.