Menu
popagent
publicLatest change 22e859e348543a86a311c69c2d20a2c27168a212 - Fix Mastra lifecycle gaps, human task cards, and rate-limited test models by AkurAI Build
import { Memory } from "@mastra/memory";
import { PostgresStoreVNext } from "@mastra/pg";
import { AGENT_CONTEXT_KEYS, agentContextValue } from "./agent-context";
import { resolveModel } from "./models";
const connectionString = process.env.DATABASE_URL;
const observabilityConnectionString = process.env.OBSERVABILITY_DATABASE_URL;
if (!connectionString) throw new Error("DATABASE_URL is required");
if (!observabilityConnectionString) throw new Error("OBSERVABILITY_DATABASE_URL is required");
export const storage = new PostgresStoreVNext({
id: "popagent-postgres",
connectionString,
observability: {
connectionString: observabilityConnectionString,
partitioning: { mode: "auto" },
},
});
export const memory = new Memory({
storage,
options: {
lastMessages: 20,
observationalMemory: {
enabled: false,
model: ({ requestContext }) => {
const settings = agentContextValue(requestContext, AGENT_CONTEXT_KEYS.runtimeSettings);
if (!settings) throw new Error("Agent runtime settings are required for observational memory");
return resolveModel(settings.defaultModel);
},
observation: { bufferOnIdle: true },
retrieval: true,
},
},
});