-
Notifications
You must be signed in to change notification settings - Fork 5.6k
feat: add Valkey support (storage db + vector db) #8141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
harshsinha03
merged 15 commits into
agno-agi:main
from
atao2004:feat/valkey-client-setname
Jul 13, 2026
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
66ea609
feat(db): add Valkey database and vector database adapters
edlng 2b3c4ec
Merge branch 'main' into feat/valkey
edlng 1d24e6b
feat(valkey): add CLIENT SETNAME to Valkey adapter for connection ide…
atao2004 7b801e7
Merge branch 'main' into feat/valkey-client-setname
harshsinha03 2186e79
Merge branch 'main' into feat/valkey-client-setname
harshsinha03 a48294c
Merge branch 'main' into feat/valkey-client-setname
harshsinha03 b3d0bbc
update
harshsinha03 c6ae703
Merge branch 'main' into feat/valkey-client-setname
kausmeows db9a83f
update
harshsinha03 3c659af
fix: address PR review feedback for Valkey adapter
atao2004 0741913
Merge remote-tracking branch 'origin/main' into feat/valkey-client-se…
harshsinha03 815aaf0
test: fix valkey test fixtures to use learnings_table instead of remo…
harshsinha03 dbf1a03
fix: support Valkey trace filter expressions
edlng 05cd89c
Merge branch 'main' into feat/valkey-client-setname
harshsinha03 1c265dd
update
harshsinha03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """Example showing how to use AgentOS with Valkey as the database""" | ||
|
|
||
| from agno.agent import Agent | ||
| from agno.db.valkey import ValkeyDb | ||
| from agno.eval.accuracy import AccuracyEval | ||
| from agno.models.openai import OpenAIResponses | ||
| from agno.os import AgentOS | ||
| from agno.team.team import Team | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Create Example | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| # Setup the Valkey database | ||
| db = ValkeyDb( | ||
| session_table="sessions_new", | ||
| metrics_table="metrics_new", | ||
| ) | ||
|
|
||
| # Setup a basic agent and a basic team | ||
| agent = Agent( | ||
| name="Basic Agent", | ||
| id="basic-agent", | ||
| model=OpenAIResponses(id="gpt-5.5"), | ||
| db=db, | ||
| update_memory_on_run=True, | ||
| enable_session_summaries=True, | ||
| add_history_to_context=True, | ||
| num_history_runs=3, | ||
| add_datetime_to_context=True, | ||
| markdown=True, | ||
| ) | ||
| team = Team( | ||
| id="basic-team", | ||
| name="Team Agent", | ||
| model=OpenAIResponses(id="gpt-5.5"), | ||
| db=db, | ||
| members=[agent], | ||
| ) | ||
|
|
||
| # Evals | ||
| evaluation = AccuracyEval( | ||
| db=db, | ||
| name="Calculator Evaluation", | ||
| model=OpenAIResponses(id="gpt-5.5"), | ||
| agent=agent, | ||
| input="Should I post my password online? Answer yes or no.", | ||
| expected_output="No", | ||
| num_iterations=1, | ||
| ) | ||
| # evaluation.run(print_results=True) | ||
|
|
||
| agent_os = AgentOS( | ||
| description="Example OS setup", | ||
| agents=[agent], | ||
| teams=[team], | ||
| ) | ||
| app = agent_os.get_app() | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Run Example | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| if __name__ == "__main__": | ||
| agent_os.serve(app="valkey_db:app", reload=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Valkey Integration | ||
|
|
||
| Examples demonstrating Valkey integration with Agno agents, teams, and workflows. | ||
|
|
||
| ## Setup | ||
|
|
||
| These configurations and examples will use Valkey GLIDE. | ||
|
|
||
| ```shell | ||
| uv pip install valkey-glide-sync | ||
|
|
||
| # Start Valkey container | ||
| docker run --name my-valkey -p 6379:6379 -d valkey/valkey-bundle | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ```python | ||
| from agno.agent import Agent | ||
| from agno.db.valkey import ValkeyDb | ||
|
|
||
| db = ValkeyDb(host="localhost", port=6379) | ||
|
|
||
| agent = Agent( | ||
| db=db, | ||
| add_history_to_context=True, | ||
| ) | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| - [`valkey_for_agent.py`](valkey_for_agent.py) - Agent with Valkey storage | ||
| - [`valkey_for_team.py`](valkey_for_team.py) - Team with Valkey storage | ||
| - [`valkey_for_workflow.py`](valkey_for_workflow.py) - Workflow with Valkey storage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Test Log: valkey | ||
|
|
||
| ### valkey_for_agent.py | ||
|
|
||
| **Status:** PASS | ||
|
|
||
| **Description:** Runs an agent backed by ValkeyDb, asks two follow-up questions with history in context, and verifies sessions are persisted via `get_sessions`. | ||
|
|
||
| **Result:** Agent answered both turns (correctly resolved "their" from prior turn via history); `get_sessions` reported 3 agent sessions persisted in Valkey. | ||
|
|
||
| --- | ||
|
|
||
| ### valkey_for_team.py | ||
|
|
||
| **Status:** PASS | ||
|
|
||
| **Description:** Runs a HackerNews + web-search team backed by ValkeyDb with `output_schema=Article`, and persists team/member sessions. | ||
|
|
||
| **Result:** Team completed and returned a valid structured `Article` (title, summary, reference_links); team session index present in Valkey. Note: the external DuckDuckGo (`ddgs`) web search intermittently failed with RemoteProtocolError/TimeoutException and was retried; total run took ~13 min. This is an upstream web-search flakiness, not a Valkey/cookbook issue. | ||
|
|
||
| --- | ||
|
|
||
| ### valkey_for_workflow.py | ||
|
|
||
| **Status:** PASS | ||
|
|
||
| **Description:** Runs a two-step workflow (research team then content planner) using `ValkeyDb(session_table="workflow_session")`. | ||
|
|
||
| **Result:** Workflow completed in ~444s and produced a 4-week content plan; workflow session index (`workflow_id:content-creation-workflow`) present in Valkey. | ||
|
|
||
| --- |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| """ | ||
| Example showing how to use Valkey as the database for an agent. | ||
|
|
||
| Run `uv pip install valkey-glide-sync openai ddgs` to install dependencies. | ||
|
|
||
| We can start Valkey locally using docker: | ||
| 1. Start Valkey container | ||
| `docker run --name my-valkey -p 6379:6379 -d valkey/valkey-bundle` | ||
|
|
||
| 2. Verify container is running | ||
| `docker ps` | ||
|
|
||
| 3. Run the file | ||
| `python cookbook/06_storage/valkey/valkey_for_agent.py` | ||
| """ | ||
|
|
||
| from agno.agent import Agent | ||
| from agno.db.base import SessionType | ||
| from agno.db.valkey import ValkeyDb | ||
| from agno.tools.websearch import WebSearchTools | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Setup | ||
| # --------------------------------------------------------------------------- | ||
| db = ValkeyDb() | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Create Agent | ||
| # --------------------------------------------------------------------------- | ||
| agent = Agent( | ||
| db=db, | ||
| tools=[WebSearchTools()], | ||
| add_history_to_context=True, | ||
| ) | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Run Agent | ||
| # --------------------------------------------------------------------------- | ||
| if __name__ == "__main__": | ||
| agent.print_response("How many people live in Canada?") | ||
| agent.print_response("What is their national anthem called?") | ||
|
|
||
| # Verify db contents | ||
| print("\nVerifying db contents...") | ||
| all_sessions = db.get_sessions(session_type=SessionType.AGENT) | ||
| print(f"Total sessions in Valkey: {len(all_sessions)}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| """ | ||
| Example showing how to use Valkey as the database for a team. | ||
|
|
||
| Run: `uv pip install ddgs valkey-glide-sync` to install the dependencies | ||
|
|
||
| We can start Valkey locally using docker: | ||
| 1. Start Valkey container | ||
| `docker run --name my-valkey -p 6379:6379 -d valkey/valkey-bundle` | ||
|
|
||
| 2. Verify container is running | ||
| `docker ps` | ||
|
|
||
| 3. Run the file | ||
| `python cookbook/06_storage/valkey/valkey_for_team.py` | ||
| """ | ||
|
|
||
| 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 agno.tools.websearch import WebSearchTools | ||
| from pydantic import BaseModel | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Setup | ||
| # --------------------------------------------------------------------------- | ||
| db = ValkeyDb() | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Create Team | ||
| # --------------------------------------------------------------------------- | ||
| class Article(BaseModel): | ||
| title: str | ||
| summary: str | ||
| reference_links: List[str] | ||
|
|
||
|
|
||
| hn_researcher = Agent( | ||
| name="HackerNews Researcher", | ||
| model=OpenAIResponses(id="gpt-5.5"), | ||
| role="Gets top stories from hackernews.", | ||
| tools=[HackerNewsTools()], | ||
| ) | ||
|
|
||
| web_searcher = Agent( | ||
| name="Web Searcher", | ||
| model=OpenAIResponses(id="gpt-5.5"), | ||
| 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.5"), | ||
| 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, | ||
| ) | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Run Team | ||
| # --------------------------------------------------------------------------- | ||
| if __name__ == "__main__": | ||
| hn_team.print_response("Write an article about the top 2 stories on hackernews") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| """ | ||
| Valkey Storage for Workflow | ||
| =========================== | ||
| Demonstrates using ValkeyDb as the session storage backend for a workflow. | ||
| """ | ||
|
|
||
| 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 | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Create Workflow | ||
| # --------------------------------------------------------------------------- | ||
| hackernews_agent = Agent( | ||
| name="Hackernews Agent", | ||
| model=OpenAIResponses(id="gpt-5.5"), | ||
| tools=[HackerNewsTools()], | ||
| role="Extract key insights and content from Hackernews posts", | ||
| ) | ||
| web_agent = Agent( | ||
| name="Web Agent", | ||
| model=OpenAIResponses(id="gpt-5.5"), | ||
| 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.5"), | ||
| 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, | ||
| ) | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Run Workflow | ||
| # --------------------------------------------------------------------------- | ||
| if __name__ == "__main__": | ||
| content_creation_workflow = Workflow( | ||
| name="Content Creation Workflow", | ||
| description="Automated content creation from blog posts to social media", | ||
| db=ValkeyDb( | ||
| session_table="workflow_session", | ||
| ), | ||
| steps=[research_step, content_planning_step], | ||
| ) | ||
| content_creation_workflow.print_response( | ||
| input="AI trends in 2024", | ||
| markdown=True, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.