From 1b2bfc0e3a581c4b6aecd610c53ff63afad5b92a Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Tue, 1 Apr 2025 17:37:16 +0200 Subject: [PATCH] Made agno work with memory --- .gitignore | 4 +++- scripts/agno_agent.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 754b0195..886b8d49 100644 --- a/.gitignore +++ b/.gitignore @@ -144,4 +144,6 @@ pylint.html /src/multilspy/language_servers/*/static # Cache is in .multilspy -**/.multilspy/** \ No newline at end of file +**/.multilspy/** + +tmp/ diff --git a/scripts/agno_agent.py b/scripts/agno_agent.py index 25b61ce1..a105a3fa 100644 --- a/scripts/agno_agent.py +++ b/scripts/agno_agent.py @@ -7,6 +7,7 @@ from agno.models.anthropic.claude import Claude from agno.models.google.gemini import Gemini from agno.playground.playground import Playground from agno.playground.serve import serve_playground_app +from agno.storage.agent.sqlite import SqliteAgentStorage from dotenv import load_dotenv from sensai.util import logging from sensai.util.helper import mark_used @@ -24,12 +25,24 @@ load_dotenv() project_file_path = "../myproject.yml" serena_agent = SerenaAgent(project_file_path, start_language_server=True) +# Even though we don't want to keep history between sessions, +# for the agno ui to work as a conversation, we a persistent storage on disk +# This storage should be deleted between sessions. +# Note that this might collide with custom options for the agent, like adding vector-search based tools. +# See here for an explanation: https://www.reddit.com/r/agno/comments/1jk6qea/regarding_the_built_in_memory/ +sql_db_path = os.path.join("tmp", "agent_storage.db") +os.makedirs(os.path.dirname(sql_db_path), exist_ok=True) +# delete the db file if it exists +if os.path.exists(sql_db_path): + os.remove(sql_db_path) + model = Claude(id="claude-3-7-sonnet-20250219") # model = Gemini(id="gemini-2.5-pro-exp-03-25") agno_agent = Agent( name="Serena", model=model, + storage=SqliteAgentStorage(table_name="serena_agent_sessions", db_file=sql_db_path), description="A fully-featured coding assistant", tools=[SerenaAgnoToolkit(serena_agent)], # type: ignore show_tool_calls=False,