Guide to migrate your Agno applications from v1 to v2.
Storage
or Memory
functionalities to store Agent sessions and memories in your database, you can start by migrating your tables.
libs/agno/scripts/migrate_to_v2.py
Agent
and Team
classes:
1.1. Streaming responses with arun
now returns an AsyncIterator
, not a coroutine. This is how you consume the resulting events now, when streaming a run:
RunResponse
class is now RunOutput
. This is the type of the results you get when running an Agent:
RunOutputStartedEvent
→ RunStartedEvent
RunOutputCompletedEvent
→ RunCompletedEvent
RunOutputErrorEvent
→ RunErrorEvent
RunOutputCancelledEvent
→ RunCancelledEvent
RunOutputContinuedEvent
→ RunContinuedEvent
RunOutputPausedEvent
→ RunPausedEvent
RunOutputContentEvent
→ RunContentEvent
TeamRunOutputStartedEvent
→ TeamRunStartedEvent
TeamRunOutputCompletedEvent
→ TeamRunCompletedEvent
TeamRunOutputErrorEvent
→ TeamRunErrorEvent
TeamRunOutputCancelledEvent
→ TeamRunCancelledEvent
TeamRunOutputContentEvent
→ TeamRunContentEvent
Storage
classes have moved from agno/storage
to agno/db
. We will now refer to them as our Db
classes.
2.2. The mode
parameter has been deprecated. The same instance can now be used by Agents, Teams and Workflows.
table_name
parameter has been deprecated. One instance now handles multiple tables, you can define their names individually.
Team
would create a team session and sessions for every team member participating in the run. Now, only the Team
session is created. The runs for the team leader and all members can be found in the Team
session.
MemoryDb
classes have been deprecated. The main Db
classes are to be used.
3.2. The Memory
class has been deprecated. You now just need to set enable_user_memories=True
on an Agent with a db
for Memory to work.
memories_table
. By default, the agno_memories
will be used. It will be created if needed. You can also set the memory table like this:
db
object. For example:
AgentKnowledge
has been deprecated in favor of the new Knowledge
class.
Along with this, all of the child classes that used AgentKnowledge
as a base have been removed. Their capabilities are now supported
by default in Knowledge
. This also means that the correct reader for the content that you are adding is now selected automatically, with
the option to override it at any time.
4.2. The load()
method and its variations have been replaced by add_content()
. Content is the building block of any piece of knowledge originating
from any sources. For a full example of the usage, see the Content Types page.
4.3. Knowledge
now supports a contents_db
. This allows the storage and management of every piece of content that is added to your knowledge.
Furthermore, we now support deletion of individual vectors using the remove_vectors_by_id()
, remove_vectors_by_name()
and remove_vectors by metadata()methods. You can also delete all vectors created by a specific piece of content using
remove_content_by_id()`.
4.4 In order to support the deletion mentioned above, VectorDB tables have been updated. Two new columns, content_hash
and content_id
have been added.
4.5. The retriever
field has been renamed to knowledge_retriever
.
4.6. The add_references
method has been renamed to add_knowledge_to_context
.
Renamed
retriever
-> knowledge_retriever
add_references
-> add_knowledge_to_context
time
field has been renamed to duration
.
5.2. Provider-specific metrics fields are now to be found inside the provider_metrics
field.
5.3. A new additional_metrics
field has been added for you to add any extra fields you need.
Team
class to be more flexible and powerful.
The biggest changes is that the mode
parameter has been deprecated. Instead there are attributes that can be used to control the behavior of the team:
respond_directly
-> If True, the team leader won’t process responses from the members and instead will return them directlydelegate_task_to_all_members
-> If True, the team leader will delegate tasks to all members simultaneously, instead of one by one. When running async (using arun
) members will run concurrently.determine_input_for_members
-> True
by default. Set to False if you want to send the run input directly to the member agents without the team leader synthesizing its own input. This is useful if you want to send pydantic model input directly to the member agents.Playground
has been deprecated. Our new AgentOS offering will substitute all usecases.
See AgentOS for more details!