Valkey for Workflow

Store workflow sessions in Valkey with ValkeyDb.

Agno supports using Valkey as a storage backend for Workflows using the ValkeyDb class.

Usage

Start in a virtual environment.

Install dependencies:

uv pip install -U agno ddgs fastapi openai valkey-glide-sync

Run Valkey

Install docker desktop and run Valkey on port 6379 using:

docker run -d \
  --name my-valkey \
  -p 6379:6379 \
  valkey/valkey

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-***
valkey_for_workflow.py
"""
Run: `uv pip install openai agno ddgs valkey-glide-sync fastapi` to install the dependencies
"""
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 agno.tools.websearch import WebSearchTools
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow

# Define agents
hackernews_agent = Agent(
    name="Hackernews Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[HackerNewsTools()],
    role="Extract key insights and content from Hackernews posts",
)
web_agent = Agent(
    name="Web Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[WebSearchTools()],
    role="Search the web for the latest news and trends",
)

# Define research team for complex analysis
research_team = Team(
    name="Research Team",
    members=[hackernews_agent, web_agent],
    instructions="Research tech topics from Hackernews and the web",
)

content_planner = Agent(
    name="Content Planner",
    model=OpenAIResponses(id="gpt-5.2"),
    instructions=[
        "Plan a content schedule over 4 weeks for the provided topic and research content",
        "Ensure that I have posts for 3 posts per week",
    ],
)

# Define steps
research_step = Step(
    name="Research Step",
    team=research_team,
)

content_planning_step = Step(
    name="Content Planning Step",
    agent=content_planner,
)

# Create and use workflow
if __name__ == "__main__":
    content_creation_workflow = Workflow(
        name="Content Creation Workflow",
        description="Automated content creation from blog posts to social media",
        db=ValkeyDb(
            host="localhost",
            port=6379,
        ),
        steps=[research_step, content_planning_step],
    )
    content_creation_workflow.print_response(
        input="AI trends in 2024",
        markdown=True,
    )

Run the example

Save the code as valkey_for_workflow.py, start the database described above, and run:

python valkey_for_workflow.py

Params

ParameterTypeDefaultDescription
idOptional[str]-Database ID. Derived deterministically from the host and port (or client representation) and key prefix when omitted.
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.
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 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.