GcsJsonDb

Store sessions, memories, metrics, knowledge, evals, and traces as JSON files in Google Cloud Storage.

GcsJsonDb is a class that implements the Db interface using Google Cloud Storage as the backend storage system. Each table is stored as a JSON file in a GCS bucket.

ParameterTypeDefaultDescription
idOptional[str]-Database ID. Derived deterministically from bucket, project and prefix when omitted.
bucket_namestr-Name of the GCS bucket where JSON files will be stored.
prefixOptional[str]-Path prefix for organizing files in the bucket. Defaults to "agno/".
session_tableOptional[str]-Name of the JSON file to store sessions (without .json extension).
runs_tableOptional[str]NoneStorage name for individual runs. Defaults to agno_runs, or <session_table>_runs when a custom session name is supplied.
memory_tableOptional[str]-Name of the JSON file to store user memories.
metrics_tableOptional[str]-Name of the JSON file to store metrics.
eval_tableOptional[str]-Name of the JSON file to store evaluation runs.
knowledge_tableOptional[str]-Name of the JSON file to store knowledge content.
traces_tableOptional[str]-Name of the JSON file to store traces.
spans_tableOptional[str]-Name of the JSON file to store spans.
projectOptional[str]-GCP project ID. If None, uses default project.
credentialsOptional[Any]-GCP credentials. If None, uses default credentials.

Methods

upsert_sessions

Upsert multiple sessions in one method call.

Parameters:

  • sessions (List[Session]): List of sessions to upsert
  • deserialize (Optional[bool]): Whether to deserialize the sessions. Defaults to True
  • preserve_updated_at (bool): Request preservation of the sessions' existing updated_at timestamps; see adapter limitations below. Defaults to False

Returns: List[Union[Session, Dict[str, Any]]]

upsert_memories

Upsert multiple memories in one method call.

Parameters:

  • memories (List[UserMemory]): List of memories to upsert
  • deserialize (Optional[bool]): Whether to deserialize the memories. Defaults to True
  • preserve_updated_at (bool): Request preservation of the memories' existing updated_at timestamps; see adapter limitations below. Defaults to False

Returns: List[Union[UserMemory, Dict[str, Any]]]

Timestamp preservation by adapter

JsonDb, GcsJsonDb, FirestoreDb, RedisDb, DynamoDb, and InMemoryDb accept preserve_updated_at but do not forward it to their individual upserts. Their bulk methods replace timestamps even when it is True.

PostgresDb, SingleStoreDb, and ValkeyDb honor the flag. MySQLDb, SqliteDb, and MongoDb honor it on their optimized bulk path; their per-record fallback paths do not forward it. Verify timestamps when a migration depends on preserving them.

GcsJsonDb accepts multiple records through the bulk methods but processes each record with an individual upsert. These methods do not reduce GCS read and write operations. In the current implementation, preserve_updated_at is accepted but ignored, so an upsert replaces the existing timestamp.