This guide shows how to run agents with long-term memory by using sessions. This works on the server-side only.

In your server-side Scoopika initialization, you can pass a remote store ID that you can create here to have persistent memory and chat sessions, otherwise Scoopika will use an in-memory store (not persistent).

All data in remote memory stores is encrypted and never accessed by our team!

Create session

Let’s create a new session, in this case We’ll create a session for a user with the ID “SCOOP” so we can then list SCOOP’s sessions. You can use this approach to create sessions for specific users in your app based on their IDs.

const session = await scoopika.memory.newSession({
	user_id: "SCOOP" // optional
});

Run agent

Now we can pass that session’s id to each agent run to save the run to that session, example:

await agent.run({
	options: {
		session_id: session.id
	},
	inputs: {
		message: "Hello, I'm Kais",
	}
});

Notice that we passed the session_id as the session’s ID we previously created, so now we can run the agent again and it will remember was we said earlier:

await agent.run({
	options: {
		session_id: session.id
	},
	inputs: {
		message: "Who am I?",
	}
});

Get session messages

Now we can check that session’s messages (history, it contains the user request and agent response):

await scoopika.memory.getSessionMessages(session.id);

List user sessions

and we can list SCOOP’s sessions, and it will return the IDs of sessions that SCOOP owns:

await scoopika.memory.listUserSessions(session.id);

Delete session

You can also delete a session if you want to:

await scoopika.memory.deleteSession(session.id);

See how easy and simple that is, history is managed for you, you just pass sessions IDs to runs!