Memory types
Configure memory on your agent to persist messages across requests:Buffer memory
Keeps the last N messages. Simple and predictable:Conversation memory
Sliding window based on token count. Drops the oldest messages when the limit is reached:Summary memory
Automatically summarizes older messages to fit more context into fewer tokens:Redis memory
For production deployments where multiple server instances share state:Memory operations
Access memory programmatically in API routes:getMemoryStats() returns:
Streaming
Server-side streaming
agent.stream() returns an AgentStreamResult that converts to a standard Response:
toDataStreamResponse() returns a streaming Response with the text/event-stream content type, compatible with the useChat hook on the client.
Client-side consumption
TheuseChat hook handles the streaming protocol automatically:
Non-streaming generation
Usegenerate() when you need the complete response at once:
Client-managed vs server-managed memory
There are two patterns for conversation history: Client-managed (default withuseChat): The client sends the full message array on each request. The server is stateless. Good for simple chat UIs.
Server-managed (with agent memory): The server persists messages. The client sends only the latest message. Good for long-running conversations and multi-device access.
You can combine both: use client memory for the UI and server memory for context that persists across sessions.
Next
Related
veryfront/agent: agent API referenceveryfront/chat: chat hooks API reference