Sessions and Memory
How session context works, when to reuse sessions, and how to control retention.
Liya Engine maintains conversational context through sessions. Each session is a persistent conversation thread tied to a user_id and a domain. The engine uses session history to deliver more relevant, contextual responses.
How sessions work
- On your first call, omit
session_id— the engine creates a new session and returns its ID. - On follow-up calls, pass the same
session_idto continue the conversation. - Sessions expire after a period of inactivity (default: 30 days — configurable via Data Retention).
What the engine remembers
Within a session, the engine retains:
- All prior messages (user inputs + assistant responses)
- Intent results from earlier in the session
- User context fields like
user_idandpreferences
This means if you've already run resume_analysis, a subsequent career_path_planning call in the same session will reference the analysis without you resending the resume.
Session scope
Sessions are scoped to a single domain. Mixing intents from different domains in the same session is not supported — create a new session when switching domains.
Sessions are also scoped by tenant_id — no session data is shared between tenants.
Starting a fresh session
To force a new context, omit session_id on your next call:
The old session remains accessible via GET /dashboard/sessions/:sessionId until it expires.
Agentic sessions
When agenticConfig.mode is "auto" or "always", the engine can autonomously chain multiple intents within a session to complete a complex goal. In this mode:
- The engine may call several intents internally before responding
- Token usage reflects all internal steps
- The session
messageCountincrements for each internal step
See Feature Configuration to configure agentic behaviour.
Memory and data retention
| What | Default retention | Configurable |
|---|---|---|
| Session record | 30 days inactivity | session_retention_days |
| Message content | 90 days | message_retention_days |
| PII in messages | 7 days | pii_retention_days |
Set any retention field to null to disable automatic purging.
Opt-out per request
Individual requests can opt out of storage entirely using the consent block:
When allow_data_storage: false, the request is processed but no messages or session data are stored. The session ID returned will be ephemeral.
See Data Retention for the full consent schema.
Inspecting sessions
Use the Dashboard API to review session history:
See Sessions API.