Session services vs memory services
Set up ADK memory
1
Navigate to the memory step
During agent creation or editing, navigate to the Memory step in the agent form.
2
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
3
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
4
Save and restart
Click Next to continue, then finalize with Save changes. Restart the agent to apply the new configuration.
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.
Configuration: No additional configuration required.
Vertex AI session service
TheVertexAiSessionService uses Google Cloud’s Vertex AI infrastructure for session management.
Configuration: Requires the following fields:
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.
Configuration: Requires a database connection string.
Memory service options
Memory services manage long-term knowledge storage that persists across multiple sessions.In-memory memory service
TheInMemoryMemoryService provides ephemeral memory storage.
Configuration: No additional configuration required.
Vertex AI memory service
TheVertexAiMemoryService provides cloud-backed memory with long-term storage using Vertex AI Memory Banks.
Configuration: Requires the following fields:
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: Use the Verify button on the memory configuration card to check connectivity. If the standalone runs in Docker and the database is on the host, use
host.docker.internalinstead oflocalhost - 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
Next steps
Google ADK framework
Configure the ADK adapter and Gemini-powered agents.
Guardrails
Add safety guards to your agent inputs and outputs.
Observability
Trace runs, monitor latency, and inspect token usage.