tenant-adminUpdated 2026-05-01

Agent Session Memory

What this covers

The conversational agent maintains a history of turns (question-answer pairs) within each conversation. This page explains how session memory works, how the history depth setting affects prompt construction, and how to manage conversation data through stats and purge controls.

How session memory works

Each conversation between a user and the agent is stored as a sequence of turns. A turn consists of the user's question and the agent's response (answer text, citations, thought process, and metadata).

When a new question arrives, the agent includes prior turns in the LLM prompt so the model has conversational context. This allows the agent to handle follow-up questions ("what about last quarter?"), resolve pronouns ("show me that by region"), and maintain coherence across a multi-turn conversation.

The trade-off is that more history means a larger prompt, which consumes more LLM tokens and increases latency. The session history depth setting controls this trade-off.

Session history depth

The session_history_depth setting (default: 20) controls how many recent turns include the full agent response in the prompt. Older turns are still included but in a compressed form: only the user's question appears, prefixed with [earlier question]. The agent's response is omitted.

This design preserves the thread of the conversation (the user can still see what they asked earlier) while keeping the prompt size bounded.

How it works

For a conversation with 30 turns and a depth of 20:

The boundary moves as the conversation grows. A conversation with fewer turns than the depth setting includes all turns in full.

Choosing a depth

ScenarioSuggested depth
Short, focused Q&A sessions (most use cases)10--20
Long analytical conversations with many follow-ups30--50
High-throughput API usage where token cost matters5--10
Models with very long agent responses5--15

Configure the depth in the project agent settings:

  1. Open Tenant Administration > Projects.
  2. Click the gear icon on the project row.
  3. Navigate to the Advanced tab under the agent settings.
  4. Set the Session history depth value (range: 1--100).
  5. Click Save.

The change takes effect on the next agent turn — it does not retroactively alter stored turns.

Conversation stats

The Advanced tab displays two statistics for the project:

These statistics are fetched from GET /api/v1/admin/agent/conversations/stats?project_id=<id>.

Purging conversations

Conversation data accumulates over time. The Advanced tab provides two purge controls:

Purge by age

Enter a number of days and click Purge. Every conversation whose last activity is older than the specified number of days is permanently deleted, along with all its turns and trace data.

Delete all

Click Delete All Conversations and type DELETE ALL in the confirmation field. Every conversation for the project is permanently removed.

Both actions are hard deletes — the data cannot be recovered. The purge operates at the conversation level: individual turns cannot be selectively deleted.

When to purge

API reference

MethodEndpointPurpose
GET/api/v1/admin/agent/conversations/statsConversation count and oldest date (requires project_id query param)
DELETE/api/v1/admin/agent/conversations/purgeDelete conversations (requires project_id and older_than_days query params; older_than_days=0 deletes all)

Both require tenant_admin role.

Relationship to retention

The conversation_retention_days setting on the Retention tab controls automatic cleanup via a scheduled job. The manual purge on the Advanced tab is an immediate, ad-hoc operation. They are independent — you can use one, both, or neither.

MechanismTriggerGranularity
Retention settingAutomatic (daily scheduler job)Conversations older than the configured number of days
Manual purgeOn-demand (admin clicks button)By age threshold or all

Best practices

Related