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 initto 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.