Package ai.acolite.agentsdk.core.memory
Class SQLiteSession
java.lang.Object
ai.acolite.agentsdk.core.memory.SQLiteSession
- All Implemented Interfaces:
Session,AutoCloseable
SQLiteSession - Database-backed session storage
Stores conversation history in SQLite database with full persistence. Suitable for: - Production applications requiring data persistence - Multi-session management - Conversation history across restarts
Schema: - agent_sessions: Session metadata (session_id, created_at, updated_at) - agent_messages: Conversation items (session_id, item_json, timestamp, sequence_num)
Thread-safety: Each operation uses the connection in a thread-safe manner. WAL mode enables concurrent reads while writes are happening.
Ported from TypeScript OpenAI Agents SDK Source: https://github.com/openai/openai-agents-js (DrizzleSession pattern)
-
Method Summary
Modifier and TypeMethodDescriptionaddItems(List<AgentInputItem> items) addItemsclearSessionvoidclose()static SQLiteSessionCreate SQLiteSession with file-based database.getItemsgetSessionIdstatic SQLiteSessionCreate SQLiteSession with in-memory database.popItem()popItem
-
Method Details
-
inMemory
Create SQLiteSession with in-memory database. Data is lost when connection closes.- Parameters:
sessionId- Unique session identifier- Returns:
- SQLiteSession instance
- Throws:
SQLException- if database initialization fails
-
fromFile
Create SQLiteSession with file-based database. Data persists across application restarts.- Parameters:
sessionId- Unique session identifierdbPath- Path to SQLite database file- Returns:
- SQLiteSession instance
- Throws:
SQLException- if database initialization fails
-
getSessionId
Description copied from interface:SessiongetSessionId- Specified by:
getSessionIdin interfaceSession- Returns:
- CompletableFuture
-
getItems
Description copied from interface:SessiongetItems -
addItems
Description copied from interface:SessionaddItems -
popItem
Description copied from interface:SessionpopItem -
clearSession
Description copied from interface:SessionclearSession- Specified by:
clearSessionin interfaceSession- Returns:
- CompletableFuture
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException
-