PAMbaseDocs
Guide

Chat assistant.

Build an LLM chat app that remembers the user across sessions. Instead of starting cold every conversation, you ground each reply in the user's memory — durable facts they've shared with any connected app — so your assistant feels like it already knows them.

Prerequisites

You have a connection token from the connect flow — the credential your app gets after the user grants access. It carries these scopes (the per-app permissions that gate what you can read and write):

identity:read, memory:read:*, memory:write:general.

Scopes to request

ScopeWhy
identity:readoptional display name + one-line tone note
memory:read:*ground the system prompt across the user's memory
memory:write:generalrecord durable facts the user shares in chat

Request the narrowest read scopes you actually use — memory:read:* is the maximal case, granting read access to every scope.

What to write

When the user shares something durable, remember it — plain text plus a kind and scope. (If you use the hosted agent below, this happens automatically from the conversation.)

typescript
const res = await pambase.remember({
content: "Prefers concise answers, no preamble.",
kind: "preference",
scope: "preference",
});
// res -> { accepted: true, memoryIds: ["mem_…"] }
await pambase.remember({ content: "Likes a direct tone.", kind: "preference", scope: "preference" });

How to read — Pattern A

Pull a bounded system prompt and pass it into your own model's system field. systemPrompt() returns a ready-to-use string built from top-K memory retrieval.

typescript
import { PAMbaseApp } from "@pambase/sdk";
import Anthropic from "@anthropic-ai/sdk";
const pambase = new PAMbaseApp({ baseUrl, connectionToken });
const system = await pambase.systemPrompt();
// system -> "You are talking to Sam, who prefers concise answers…" (a string)
const reply = await new Anthropic().messages.create({
model: "claude-sonnet-4-5",
system,
messages: [{ role: "user", content: userMessage }],
});

No model of your own? Host the turn on PAMbase with pambase.chat() (requires the ai:host:chat scope) — it grounds, replies, and auto-records memory candidates unless you pass ephemeral: true.

typescript
const { reply, toneTags, usage } = await pambase.chat({
intent: "support.reply",
userMessage: "remind me what we decided about the launch date",
});
// reply -> "You set the launch for June 3…" toneTags -> ["direct", "concise"]

Proactive (optional)

Subscribe to a webhook — a server-to-server callback PAMbase fires when something happens — if you want to nudge the user when another app writes something relevant.

Don't dump the whole history

The system prompt is bounded by top-K retrieval — let systemPrompt() do the selection. Concatenating every memory blows your context window and degrades the reply. More in the chat how-to.

Next

Hosted chat & streaming · How memory works · Scopes & permissions