# getHistory()

Canonical URL: https://developers.iagenify.com/sdk/ref/local-agent/get-history/
Language: en

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

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

Status: free · same shape as a model session · source depends on memory

```javascript
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);
  }
}
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `role` | string |  | `user` or `assistant`. Tool messages are not in it. |
| `parts` | array |  | `[{ type: "text", content }]` — the same shape a model session returns. |
| `toolCalls` | array |  | `{ id, name, target, ok, credits, durationMs }` per call. |

## target is the short version of the arguments {#target}

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 {#source}

| Agent | Read from |
| --- | --- |
| Without `memory` | What the object holds in memory |
| With `memory` | The 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 {#display}

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.

- [Sessions](/sdk/agent/sessions): What is kept, and where.
- [agents.list()](/sdk/ref/agents/list): Finding a conversation.

```python
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])
```
