Overview
TheSession class represents a conversation session. It provides methods for adding messages, retrieving context, and processing sessions.
Properties
Unique identifier for the session.
Current session status:
PENDING, PROCESSING, PROCESSED, or FAILED.Session metadata as an object.
UTC timestamp when the session was created.
Message Methods
addMessage()
Message role:
USER or ASSISTANT.Message content text.
Context Retrieval
getContext()
Strategy for memory retrieval:
LOW_LATENCY, BALANCED, AGENTIC, or AUTO.Minimum number of memories to return. Range: 5-50.
Maximum number of memories to return. Range: 10-100.
Similarity threshold for memories. Range: 0.2-0.8.
Similarity threshold for summaries. Range: 0.2-0.8.
Number of last messages to include in context. Range: 1-100.
Number of last summaries to include in context. Range: 1-20.
Timezone for formatting timestamps (e.g., “America/New_York”).
Whether to include the default RecallrAI system prompt.
Whether to include memory IDs and session IDs that contributed to the context.
ContextResponse object with:
Always
true for non-streaming responses.The formatted context string containing relevant memories and conversation history.
Only present when
includeMetadataIds=true. Contains:memoryIds: Array of memory IDs that contributed to the contextsessionIds: Array of session IDs that contributed to the contextagentReasoning: (Optional) Agent’s reasoning process, only populated when using agentic recall strategyvectorSearchQueries: (Optional) Vector search queries generated for recallkeywords: (Optional) Keywords extracted for recallsessionSummariesSearchQueries: (Optional) Queries used to search session summariesdateRangeFilters: (Optional) Date range filters extracted from the query (balanced recall only)
getContextStream()
Stream context events with status updates and structured metadata.Whether to include context metadata (IDs, queries, filters, and agent reasoning in status events) in the response.
ContextResponse objects with the following fields:
Indicates whether this is the final event or a status update.
Human-readable status update message (only present when
isFinal is false).Error message if an error occurred during context generation.
The formatted context string (only present when
isFinal is true).Only present when
includeMetadataIds=true and isFinal=true. Contains:memoryIds: Array of memory IDs that contributed to the contextsessionIds: Array of session IDs that contributed to the contextagentReasoning: (Optional) Agent’s reasoning process, only populated when using agentic recall strategyvectorSearchQueries: (Optional) Vector search queries generated for recallkeywords: (Optional) Keywords extracted for recallsessionSummariesSearchQueries: (Optional) Queries used to search session summariesdateRangeFilters: (Optional) Date range filters extracted from the query (balanced recall only)