Skip to main content
Agno supports using Valkey as a storage backend for Teams using the ValkeyDb class.

Usage

Run Valkey

Install docker desktop and run Valkey on port 6379 using:
docker run -d \
  --name my-valkey \
  -p 6379:6379 \
  valkey/valkey
valkey_for_team.py
"""
Run: `uv pip install openai agno valkey-glide-sync` to install the dependencies
"""

from typing import List

from agno.agent import Agent
from agno.db.valkey import ValkeyDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from pydantic import BaseModel

db = ValkeyDb(
    host="localhost",
    port=6379,
)

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=[HackerNewsTools()],
    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]-The ID of the database instance. UUID by default.
valkey_clientOptional[Union[GlideClient, GlideClusterClient]]-Pre-configured Valkey GLIDE client. If not provided a new client will be created.
hoststr"localhost"Valkey server host.
portint6379Valkey server port.
database_idOptional[int]-Logical database index (e.g. 0-15).
usernameOptional[str]-Username for authentication.
passwordOptional[str]-Password for authentication.
use_tlsboolFalseEnable TLS encryption.
request_timeoutOptional[int]-Milliseconds to wait for a request to complete. If unset, the GLIDE client default (250 ms) applies.
db_prefixstr"agno"Prefix for all Valkey keys.
client_namestr"agno_db_client"Connection name, visible in CLIENT LIST.
expireOptional[int]-TTL for Valkey keys in seconds.
session_tableOptional[str]-Name of the table to store sessions.
memory_tableOptional[str]-Name of the table to store memories.
metrics_tableOptional[str]-Name of the table to store metrics.
eval_tableOptional[str]-Name of the table to store evaluation runs.
knowledge_tableOptional[str]-Name of the table to store knowledge documents.
traces_tableOptional[str]-Name of the table to store traces.
spans_tableOptional[str]-Name of the table to store spans.
learnings_tableOptional[str]-Name of the table to store learnings.