GcsJsonDb
class. This storage backend stores session data as JSON blobs in a GCS bucket.
Usage
Configure your agent with GCS storage to enable cloud-based session persistence.gcs_for_agent.py
Prerequisites
1
Google Cloud SDK Setup
- Install the Google Cloud SDK
- Run
gcloud init
to configure your account and project
2
GCS Permissions
Ensure your account has sufficient permissions (e.g., Storage Admin) to create and manage GCS buckets:
3
Authentication
Use default credentials from your gcloud CLI session:Alternatively, if using a service account, set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to the path of your service account JSON file.4
Python Dependencies
Install the required Python packages:
1
Setup with Docker
For local testing without using real GCS, you can use fake-gcs-server.Create a Start the fake GCS server:
docker-compose.yml
file:2
Using Fake GCS with Docker
Set the environment variable to direct API calls to the emulator:When using Fake GCS, authentication isn't enforced and the client will automatically detect the emulator endpoint.
Params
Parameter | Type | Default | Description |
---|---|---|---|
bucket_name | str | - | Name of the GCS bucket where JSON files will be stored. |
prefix | Optional[str] | - | Path prefix for organizing files in the bucket. Defaults to "agno/". |
session_table | Optional[str] | - | Name of the JSON file to store sessions (without .json extension). |
memory_table | Optional[str] | - | Name of the JSON file to store user memories. |
metrics_table | Optional[str] | - | Name of the JSON file to store metrics. |
eval_table | Optional[str] | - | Name of the JSON file to store evaluation runs. |
knowledge_table | Optional[str] | - | Name of the JSON file to store knowledge content. |
project | Optional[str] | - | GCP project ID. If None, uses default project. |
credentials | Optional[Any] | - | GCP credentials. If None, uses default credentials. |
Developer Resources
- View Cookbook