diff --git a/cookbook/agent_os/basic.py b/cookbook/agent_os/basic.py index 31d4cfdbdbb..338d6adbc31 100644 --- a/cookbook/agent_os/basic.py +++ b/cookbook/agent_os/basic.py @@ -42,6 +42,7 @@ agent=basic_agent, ) ], + add_workflow_history_to_steps=True, ) # Setup our AgentOS app diff --git a/cookbook/agents/session/02_persistent_session_history.py b/cookbook/agents/session/02_persistent_session_history.py index 880426884f9..2d71ad2c6a8 100644 --- a/cookbook/agents/session/02_persistent_session_history.py +++ b/cookbook/agents/session/02_persistent_session_history.py @@ -15,9 +15,11 @@ agent = Agent( model=OpenAIChat(id="gpt-4o-mini"), db=db, - session_id="session_storage", add_history_to_context=True, - num_history_runs=2, + num_history_runs=3, ) agent.print_response("Tell me a new interesting fact about space") +agent.print_response("Tell me a new interesting fact about oceans") + +agent.print_response("What have we been talking about?") diff --git a/cookbook/db/json_db/json_for_agent.py b/cookbook/db/json_db/json_for_agent.py index 455e2d379ed..c0019ce46d6 100644 --- a/cookbook/db/json_db/json_for_agent.py +++ b/cookbook/db/json_db/json_for_agent.py @@ -15,8 +15,11 @@ agent = Agent( model=OpenAIChat(id="gpt-4o-mini"), db=db, + session_id="session_storage", tools=[DuckDuckGoTools()], add_history_to_context=True, + num_history_runs=3, ) -agent.print_response("How many people live in Canada?") +agent.print_response("How many people live in France?") agent.print_response("What is their national anthem called?") +agent.print_response("What have we been talking about?") diff --git a/libs/agno/agno/db/mongo/async_mongo.py b/libs/agno/agno/db/mongo/async_mongo.py index 12dfccaf0f1..6e864b237a6 100644 --- a/libs/agno/agno/db/mongo/async_mongo.py +++ b/libs/agno/agno/db/mongo/async_mongo.py @@ -282,7 +282,7 @@ async def _get_or_create_collection( return None # Note: Motor doesn't have sync create_index, so we use it as-is # The indexes are created in the background - create_collection_indexes(collection, collection_type) + create_collection_indexes(collection, collection_type) # type: ignore setattr(self, f"_{collection_name}_initialized", True) log_debug(f"Initialized collection '{collection_name}'") else: @@ -1088,8 +1088,8 @@ async def get_user_memory_stats( # Apply pagination if limit is not None: if page is not None: - pipeline.append({"$skip": (page - 1) * limit}) - pipeline.append({"$limit": limit}) + pipeline.append({"$skip": (page - 1) * limit}) # type: ignore + pipeline.append({"$limit": limit}) # type: ignore results = await collection.aggregate(pipeline).to_list(length=None) @@ -1584,7 +1584,7 @@ async def calculate_metrics(self) -> Optional[list[dict]]: metrics_records.append(metrics_record) if metrics_records: - results = bulk_upsert_metrics(collection, metrics_records) + results = bulk_upsert_metrics(collection, metrics_records) # type: ignore return results diff --git a/libs/agno/agno/os/schema.py b/libs/agno/agno/os/schema.py index 209bbe1bdc4..20da1842f3a 100644 --- a/libs/agno/agno/os/schema.py +++ b/libs/agno/agno/os/schema.py @@ -475,7 +475,6 @@ def filter_meaningful_config(d: Dict[str, Any], defaults: Dict[str, Any]) -> Opt team_run_context={}, check_mcp_tools=False, ) - print(team.tools, _tools) team_tools = _tools formatted_tools = format_team_tools(team_tools) if team_tools else None diff --git a/libs/agno/agno/team/team.py b/libs/agno/agno/team/team.py index 2d8c21acd40..2c7aaf0d28e 100644 --- a/libs/agno/agno/team/team.py +++ b/libs/agno/agno/team/team.py @@ -8501,7 +8501,7 @@ async def aget_relevant_docs_from_knowledge( log_warning("No valid filters remain after validation. Search will proceed without filters.") if self.knowledge_retriever is not None and callable(self.knowledge_retriever): - from inspect import signature + from inspect import isawaitable, signature try: sig = signature(self.knowledge_retriever) @@ -8511,7 +8511,13 @@ async def aget_relevant_docs_from_knowledge( if "filters" in sig.parameters: knowledge_retriever_kwargs["filters"] = filters knowledge_retriever_kwargs.update({"query": query, "num_documents": num_documents, **kwargs}) - return self.knowledge_retriever(**knowledge_retriever_kwargs) + + result = self.knowledge_retriever(**knowledge_retriever_kwargs) + + if isawaitable(result): + result = await result + + return result except Exception as e: log_warning(f"Knowledge retriever failed: {e}") raise e diff --git a/libs/agno/pyproject.toml b/libs/agno/pyproject.toml index 01482ed60fa..0979d192037 100644 --- a/libs/agno/pyproject.toml +++ b/libs/agno/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "agno" -version = "2.2.2" +version = "2.2.3" description = "Agno: a lightweight library for building Multi-Agent Systems" requires-python = ">=3.7,<4" readme = "README.md"