Firestore for Team

Store team sessions in Firestore with FirestoreDb.

Agno supports using Firestore as a storage backend for Teams using the FirestoreDb class.

Usage

Start in a virtual environment and set the model key before running the example.

Set OpenAI Key

Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.

export OPENAI_API_KEY=sk-***

You need to provide either project_id or db_client to the FirestoreDb class. Configure Application Default Credentials (gcloud auth application-default login locally, or GOOGLE_APPLICATION_CREDENTIALS for a service account). The project must already have a Firestore database and your identity must have data access. The client does not provision the project or database.

Install dependencies:

uv pip install agno openai google-cloud-firestore ddgs
firestore_for_team.py
from typing import List

from agno.agent import Agent
from agno.db.firestore import FirestoreDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from agno.tools.websearch import WebSearchTools
from pydantic import BaseModel

# Setup the Firestore database
PROJECT_ID = "agno-os-test"  # Use your project ID here
db = FirestoreDb(project_id=PROJECT_ID)

class Article(BaseModel):
    title: str
    summary: str
    reference_links: List[str]

hn_researcher = Agent(
    name="HackerNews Researcher",
    model=OpenAIResponses(id="gpt-5.2"),
    role="Gets top stories from HackerNews.",
    tools=[HackerNewsTools()],
)

web_searcher = Agent(
    name="Web Searcher",
    model=OpenAIResponses(id="gpt-5.2"),
    role="Searches the web for information on a topic",
    tools=[WebSearchTools()],
    add_datetime_to_context=True,
)

hn_team = Team(
    name="HackerNews Team",
    model=OpenAIResponses(id="gpt-5.2"),
    members=[hn_researcher, web_searcher],
    db=db,
    instructions=[
        "First, search HackerNews for what the user is asking about.",
        "Then, ask the web searcher to search for each story to get more information.",
        "Finally, provide a thoughtful and engaging summary.",
    ],
    output_schema=Article,
    markdown=True,
    show_members_responses=True,
)

hn_team.print_response("Write an article about the top 2 stories on HackerNews")

Params

ParameterTypeDefaultDescription
idOptional[str]-Database ID. Derived deterministically from project or client when omitted.
db_clientOptional[Client]-The Firestore client to use.
project_idOptional[str]-The GCP project ID for Firestore.
session_collectionOptional[str]-Name of the collection to store sessions.
runs_collectionOptional[str]NoneStorage name for individual runs. Defaults to agno_runs, or <session_collection>_runs when a custom session name is supplied.
memory_collectionOptional[str]-Name of the collection to store memories.
metrics_collectionOptional[str]-Name of the collection to store metrics.
eval_collectionOptional[str]-Name of the collection to store evaluation runs.
knowledge_collectionOptional[str]-Name of the collection to store knowledge documents.
traces_collectionOptional[str]-Name of the collection to store traces.
spans_collectionOptional[str]-Name of the collection to store spans.

Run the Example

Save the code as firestore_for_team.py, complete the prerequisites above, then run:

python firestore_for_team.py