Learning Paths
Persist Conversations
Store and replay Anvia message history across prompt runs.
Use this path when an agent needs to remember previous turns.
Goal
By the end, you should know:
- the
Message[]history shape - how to pass history into a prompt
- how to append
response.messages - where tool calls and tool results appear in history
Path
- Read Messages and History to understand the raw
Message[]shape. - Read Prompt Responses to understand
response.messages. - Read History for agent-specific history examples.
- Read Messages and History if your history includes attachments or rich content.
Minimal Shape
const history = await conversations.loadMessages(conversationId);
const response = await agent
.prompt(userInput)
.withHistory(history)
.send();
await conversations.saveMessages(conversationId, [
...history,
...response.messages,
]);Key Rule
response.messages is only the new part of the run. Append it to the history you loaded if you want a full transcript.
Add Next
| Need | Read |
|---|---|
| Tool-call history | Messages and History |
| Streaming conversation UI | Readable Streams |
| Long-term knowledge | Add Retrieval |
