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 an explicit transcript into a prompt
- how to use durable session memory
- 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 Memory and Sessions for the core-managed durable conversation model.
- Read Memory for raw SQL, Prisma, and Drizzle storage adapters.
- Read Agent History for agent-specific history examples.
- Read Messages and History if your history includes attachments or rich content.
Minimal Shape
import { Message } from "@anvia/core";
const history = await conversations.loadMessages(conversationId);
const currentPrompt = Message.user(userInput);
const response = await agent.prompt([...history, currentPrompt]).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.
For core-managed durable conversations, configure memory and prompt through a session:
const response = await agent.session(conversationId).prompt(userInput).send();Add Next
| Need | Read |
|---|---|
| Tool-call history | Messages and History |
| Streaming conversation UI | Readable Streams |
| Long-term knowledge | Add Retrieval |
