Session services vs memory services
| Session service | Memory service | |
|---|---|---|
| Purpose | Manages individual conversation state | Stores long-term knowledge across sessions |
| Scope | Single conversation (events, temporary state) | Cross-session (searchable knowledge base) |
| Required | Yes | Optional |
| Options | In Memory, Vertex AI, Database | In Memory, Vertex AI |
Set up ADK memory
Navigate to the memory step
During agent creation or editing, navigate to the Memory step in the agent form.
Configure your session service
Choose a session service backend (required for conversation state):
- In Memory: For development and testing
- Vertex AI: For production on Google Cloud
- Database: For production with SQL persistence
Configure your memory service
Choose a memory service backend (optional, for long-term memory):
- In Memory: For development and testing
- Vertex AI: For production with long-term storage
Session service options
Session services manage conversation state and events for individual sessions.In-memory session service
TheInMemorySessionService stores session data in the application’s memory.
| Property | Detail |
|---|---|
| Persistence | None. Data is lost when the application restarts. |
| Performance | Fastest option, no I/O overhead. |
| Use cases | Development, testing, quick prototyping. |
Vertex AI session service
TheVertexAiSessionService uses Google Cloud’s Vertex AI infrastructure for session management.
| Property | Detail |
|---|---|
| Persistence | Cloud-native, persistent storage. |
| Scalability | Handles high-volume, distributed deployments. |
| Integration | Works with other Google Cloud services. |
| Use cases | Production deployments on Google Cloud. |
project_id: Google Cloud project IDlocation: GCP region (for example,us-central1)reasoning_engine_app_name: Vertex AI Reasoning Engine application name
Database session service
TheDatabaseSessionService connects to a relational database (PostgreSQL, MySQL) for persistent session storage using SQLAlchemy.
| Property | Detail |
|---|---|
| Persistence | SQL-based storage with transaction support. |
| Scalability | Supports multi-instance deployments. |
| Reliability | Production-grade features including transactions and backups. |
| Use cases | Production deployments requiring SQL persistence. |
Memory service options
Memory services manage long-term knowledge storage that persists across multiple sessions.In-memory memory service
TheInMemoryMemoryService provides ephemeral memory storage.
| Property | Detail |
|---|---|
| Persistence | None. Data is lost when the application restarts. |
| Performance | Fast access, no external dependencies. |
| Use cases | Development, testing, scenarios where long-term memory is not required. |
Vertex AI memory service
TheVertexAiMemoryService provides cloud-backed memory with long-term storage using Vertex AI Memory Banks.
| Property | Detail |
|---|---|
| Persistence | Long-term, persistent storage across sessions. |
| Scalability | Cloud-native, handles large knowledge bases. |
| Search | Semantic search capabilities for retrieving relevant memories. |
| Use cases | Production deployments requiring long-term memory. |
project_id: Google Cloud project IDlocation: GCP regionmemory_bank_resource_id: Vertex AI Memory Bank resource ID
Best practices
Session services
- Use in-memory for local development: No setup required, fast iteration
- Use Database for production: Reliable SQL-based persistence with multi-instance support
- Use Vertex AI for Google Cloud production: Cloud-native and scalable
- Configure session isolation: Each conversation should have a unique session ID to prevent state leakage
Memory services
- Use in-memory for development: Fast iteration, no external dependencies
- Use Vertex AI for production: Long-term persistence with semantic search capabilities
- Ingest session data into memory: Periodically move important information from sessions to long-term memory
General
- Separate concerns: Use session services for conversation state and memory services for long-term knowledge
- Monitor storage usage: Long-running sessions and large memory stores can consume significant resources
- Implement backup strategies: Set up regular backups for production database and Vertex AI configurations
Troubleshooting
Session service issues
- Database connection errors: Verify the connection string format, credentials, and that the database server is accessible from the agent
- Vertex AI authentication: Verify Google Cloud credentials are configured and the service account has the required permissions
- Session not persisting: Confirm the session service is initialized and session IDs are used consistently
Memory service issues
- Vertex AI Memory Bank: Verify the Memory Bank resource ID is correct, the bank exists in the specified project and location, and IAM permissions are set
- Memory not accessible: Confirm the memory service is initialized and its configuration matches your setup
General
- Review logs: Check agent logs for session and memory-related errors
- Check permissions: Verify the agent has access to all required storage resources
- Verify configuration: Double-check all connection strings, credentials, and resource IDs