Hono
06 Persistence
Store Hono conversation history with app storage or Anvia memory.
Hono does not prescribe persistence. Keep storage in your application layer and pass messages into Anvia.
1. Explicit Transcript Storage
import { zValidator } from "@hono/zod-validator";
import { Message } from "@anvia/core";
import { z } from "zod";
import { supportAgent } from "./ai/support-agent";
import { conversations } from "./db/conversations";
const SupportRequest = z.object({
conversationId: z.string().min(1),
message: z.string().trim().min(1, "message is required"),
});
app.post("/api/support", zValidator("json", SupportRequest), async (c) => {
const userId = c.get("userId");
const { conversationId, message } = c.req.valid("json");
const history = await conversations.loadMessages(userId, conversationId);
const response = await supportAgent
.prompt([...history, Message.user(message)])
.send();
await conversations.saveMessages(userId, conversationId, [
...history,
...response.messages,
]);
return c.json({ output: response.output });
});2. Agent Memory
const agent = new AgentBuilder("support", model)
.memory(memoryStore, { savePolicy: "message" })
.build();
const response = await agent
.session(conversationId, { userId })
.prompt(message)
.send();Use memory when Anvia should load and append transcript messages through your store.
3. Studio During Development
You can inspect the same built agent in Studio without changing the Hono route:
import { Studio } from "@anvia/studio";
import { supportAgent } from "./ai/support-agent";
new Studio([supportAgent]).start({ port: 4021 });Studio is for local inspection and internal tooling. Your Hono app still owns product auth, routes, and persistence.
Next
Review deployment checks in Deploy. Related guides: Memory, Studio, and Event Store.
