SingleStore for Team
Store team sessions and run history in SingleStore with SingleStoreDb.
SingleStoreDb stores a Team's sessions and run history in SingleStore.
Usage
Start in a virtual environment.
Install dependencies:
uv pip install agno openai ddgs sqlalchemy pymysqlGet your SingleStore credentials from the SingleStore portal.
Set the endpoint values from your SingleStore workspace:
export SINGLESTORE_USERNAME="your_username"
export SINGLESTORE_PASSWORD="your_password"
export SINGLESTORE_HOST="your_host"
export SINGLESTORE_PORT="3306"
export SINGLESTORE_DATABASE="your_database"Set your OpenAI API key:
Set OpenAI Key
Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.
export OPENAI_API_KEY=sk-***from os import getenv
from sqlalchemy import URL
from typing import List
from agno.agent import Agent
from agno.db.singlestore import SingleStoreDb
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
db_url = URL.create(
drivername="mysql+pymysql",
username=getenv("SINGLESTORE_USERNAME"),
password=getenv("SINGLESTORE_PASSWORD"),
host=getenv("SINGLESTORE_HOST"),
port=int(getenv("SINGLESTORE_PORT", "3306")),
database=getenv("SINGLESTORE_DATABASE"),
query={"charset": "utf8mb4"},
).render_as_string(hide_password=False)
db = SingleStoreDb(db_url=db_url)
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, summarize each story and include its reference links.",
],
output_schema=Article,
markdown=True,
show_members_responses=True,
)
hn_team.print_response("Write an article about the top 2 stories on HackerNews")Run the example
Save the code as singlestore_for_team.py, ensure your SingleStore database is running, and run:
python singlestore_for_team.pyParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | Database ID. Derived deterministically from the URL (or engine URL) and schema when omitted. |
db_engine | Optional[Engine] | - | The SQLAlchemy database engine to use. |
db_schema | Optional[str] | - | The database schema to use. |
db_url | Optional[str] | - | The database URL to connect to. |
session_table | Optional[str] | - | Name of the table to store Agent, Team and Workflow sessions. |
memory_table | Optional[str] | - | Name of the table to store memories. |
metrics_table | Optional[str] | - | Name of the table to store metrics. |
eval_table | Optional[str] | - | Name of the table to store evaluation runs data. |
knowledge_table | Optional[str] | - | Name of the table to store knowledge content. |
runs_table | Optional[str] | - | Name of the table to store runs for each session. |
traces_table | Optional[str] | - | Name of the table to store traces. |
spans_table | Optional[str] | - | Name of the table to store spans. |
versions_table | Optional[str] | - | Name of the table to store schema versions. |
create_schema | bool | True | Whether to create the database schema if it doesn't exist. Set to False when the schema is managed externally. |