Skip to content

Commit 61467f7

Browse files
dirkbrndysolanky
andauthored
Release 1.3.2 (#2851)
# Changelog ## New Features: - **Redis Memory DB**: Added Redis as a storage provider for `Memory`. See here. ## Improvements: - **Memory Updates**: Various performance improvements made and convenience functions added: - `agent.get_session_summary()` → Use to get the previous session summary from the agent. - `agent.get_user_memories()` → Use to get the current user’s memories. - You can also add additional instructions to the `MemoryManager` or `SessionSummarizer`. - **Confluence Bypass SSL Verification**: If required, you can now skip SSL verification for Confluence connections. - **More Flexibility On Team Prompts**: Added `add_member_tools_to_system_message` to remove the member tool names from the system message given to the team leader, which allows flexibility to make teams transfer functions work in more cases. ## Bug Fixes: - **LiteLLM Streaming Tool Calls**: Fixed issues with tool call streaming in LiteLLM. - **E2B Casing Issue**: Fixed issues with parsed Python code that would make some values lowercase. - **Team Member IDs**: Fixed edge-cases with team member IDs causing teams to break. --------- Co-authored-by: Yash Pratap Solanky <101447028+ysolanky@users.noreply.github.com>
1 parent c20c022 commit 61467f7

File tree

18 files changed

+208
-88
lines changed

18 files changed

+208
-88
lines changed

cookbook/agent_concepts/memory/05_agent_with_memory.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
session_run = memory.runs[session_id][-1]
6565
print_chat_history(session_run)
6666

67-
memories = memory.get_user_memories(user_id=john_doe_id)
67+
# You can also get the user memories from the agent
68+
memories = agent.get_user_memories(user_id=john_doe_id)
6869
print("John Doe's memories:")
6970
pprint(memories)

cookbook/playground/teams_demo.py

-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
name="File Upload Agent",
2626
agent_id="file-upload-agent",
2727
role="Answer questions about the uploaded files",
28-
model=Claude(id="claude-3-7-sonnet-latest"),
2928
storage=PostgresStorage(
3029
table_name="agent_sessions", db_url=db_url, auto_upgrade_schema=True
3130
),
@@ -41,7 +40,6 @@
4140

4241
video_agent = Agent(
4342
name="Video Understanding Agent",
44-
model=Gemini(id="gemini-2.0-flash"),
4543
agent_id="video-understanding-agent",
4644
role="Answer questions about video files",
4745
storage=PostgresStorage(
@@ -59,7 +57,6 @@
5957
name="Audio Understanding Agent",
6058
agent_id="audio-understanding-agent",
6159
role="Answer questions about audio files",
62-
model=OpenAIChat(id="gpt-4o-audio-preview"),
6360
storage=PostgresStorage(
6461
table_name="agent_sessions", db_url=db_url, auto_upgrade_schema=True
6562
),
@@ -74,7 +71,6 @@
7471
web_agent = Agent(
7572
name="Web Agent",
7673
role="Search the web for information",
77-
model=OpenAIChat(id="gpt-4o"),
7874
tools=[DuckDuckGoTools()],
7975
agent_id="web_agent",
8076
instructions=[
@@ -93,7 +89,6 @@
9389
name="Finance Agent",
9490
role="Get financial data",
9591
agent_id="finance_agent",
96-
model=OpenAIChat(id="gpt-4o"),
9792
tools=[
9893
YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)
9994
],
@@ -114,7 +109,6 @@
114109
simple_agent = Agent(
115110
name="Simple Agent",
116111
role="Simple agent",
117-
model=OpenAIChat(id="gpt-4o"),
118112
instructions=["You are a simple agent"],
119113
memory=memory,
120114
enable_user_memories=True,
@@ -123,7 +117,6 @@
123117
research_agent = Agent(
124118
name="Research Agent",
125119
role="Research agent",
126-
model=OpenAIChat(id="gpt-4o"),
127120
instructions=["You are a research agent"],
128121
tools=[DuckDuckGoTools(), ExaTools()],
129122
agent_id="research_agent",
@@ -135,7 +128,6 @@
135128
name="Research Team",
136129
description="A team of agents that research the web",
137130
members=[research_agent, simple_agent],
138-
model=OpenAIChat(id="gpt-4o"),
139131
mode="coordinate",
140132
team_id="research_team",
141133
success_criteria=dedent("""\
@@ -191,7 +183,6 @@
191183
audio_agent,
192184
video_agent,
193185
],
194-
model=OpenAIChat(id="gpt-4o"),
195186
mode="route",
196187
team_id="financial_news_team",
197188
instructions=[

cookbook/teams/memory/03_user_memories.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@
113113
session_run = memory.runs[session_id][-1]
114114
# -*- Print chat history
115115
print_chat_history(session_run)
116-
# -*- Print team memory
117-
print_team_memory(user_id, memory.get_user_memories(user_id))
116+
# -*- Print team memory (you can also get the user memories from the team)
117+
print_team_memory(user_id, team.get_user_memories(user_id))

cookbook/teams/memory/06_team_session_summaries.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
)
8787
)
8888

89-
session_summary = memory.get_session_summary(
90-
user_id=user_id, session_id=session_id_2
91-
)
89+
# You can also get the session summary from the team
90+
session_summary = team.get_session_summary(user_id=user_id, session_id=session_id_2)
9291
print("Session Summary: ", session_summary.summary)

libs/agno/agno/agent/agent.py

+35-12
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,24 @@ def set_monitoring(self) -> None:
503503
if telemetry_env is not None:
504504
self.telemetry = telemetry_env.lower() == "true"
505505

506+
def set_default_model(self):
507+
# Use the default Model (OpenAIChat) if no model is provided
508+
if self.model is None:
509+
try:
510+
from agno.models.openai import OpenAIChat
511+
except ModuleNotFoundError as e:
512+
log_exception(e)
513+
log_error(
514+
"Agno agents use `openai` as the default model provider. "
515+
"Please provide a `model` or install `openai`."
516+
)
517+
exit(1)
518+
519+
log_info("Setting default model to OpenAI Chat")
520+
self.model = OpenAIChat(id="gpt-4o")
521+
506522
def initialize_agent(self) -> None:
523+
self.set_default_model()
507524
self.set_storage_mode()
508525
self.set_debug()
509526
self.set_agent_id()
@@ -1906,18 +1923,9 @@ def add_tools_to_model(
19061923
model.set_functions(functions=self._functions_for_model)
19071924

19081925
def update_model(self, session_id: str, async_mode: bool = False, user_id: Optional[str] = None) -> None:
1909-
# Use the default Model (OpenAIChat) if no model is provided
1910-
if self.model is None:
1911-
try:
1912-
from agno.models.openai import OpenAIChat
1913-
except ModuleNotFoundError as e:
1914-
log_exception(e)
1915-
log_error(
1916-
"Agno agents use `openai` as the default model provider. "
1917-
"Please provide a `model` or install `openai` using `pip install openai -U`."
1918-
)
1919-
exit(1)
1920-
self.model = OpenAIChat(id="gpt-4o")
1926+
self.set_default_model()
1927+
1928+
self.model = cast(Model, self.model)
19211929

19221930
# Update the response_format on the Model
19231931
if self.response_model is None:
@@ -2885,6 +2893,21 @@ def get_session_summary(self, session_id: Optional[str] = None, user_id: Optiona
28852893
else:
28862894
raise ValueError(f"Memory type {type(self.memory)} not supported")
28872895

2896+
def get_user_memories(self, user_id: Optional[str] = None):
2897+
"""Get the user memories for the given user ID."""
2898+
if self.memory is None:
2899+
return None
2900+
user_id = user_id if user_id is not None else self.user_id
2901+
if user_id is None:
2902+
user_id = "default"
2903+
2904+
if isinstance(self.memory, Memory):
2905+
return self.memory.get_user_memories(user_id=user_id)
2906+
elif isinstance(self.memory, AgentMemory):
2907+
raise ValueError("AgentMemory does not support get_user_memories")
2908+
else:
2909+
raise ValueError(f"Memory type {type(self.memory)} not supported")
2910+
28882911
def deep_copy(self, *, update: Optional[Dict[str, Any]] = None) -> Agent:
28892912
"""Create and return a deep copy of this Agent, optionally updating fields.
28902913

libs/agno/agno/eval/perf.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def _measure_time(self) -> float:
210210
# Return the elapsed time
211211
return timer.elapsed
212212

213+
213214
def _measure_memory(self, baseline: float) -> float:
214215
"""
215216
Measures peak memory usage using tracemalloc.
@@ -227,7 +228,7 @@ def _measure_memory(self, baseline: float) -> float:
227228
tracemalloc.stop()
228229

229230
# Convert to MiB and subtract baseline
230-
peak_mib = peak / (1024 * 1024)
231+
peak_mib = peak / 1024 / 1024
231232
adjusted_usage = max(0, peak_mib - baseline)
232233

233234
if self.debug_mode:
@@ -251,7 +252,7 @@ def empty_func():
251252
empty_func()
252253
_, peak = tracemalloc.get_traced_memory()
253254
tracemalloc.stop()
254-
results.append(peak / (1024 * 1024))
255+
results.append(peak / 1024 / 1024)
255256

256257
return sum(results) / len(results) if results else 0
257258

libs/agno/agno/models/azure/openai_chat.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class AzureOpenAI(OpenAILike):
4949
azure_ad_token: Optional[str] = None
5050
azure_ad_token_provider: Optional[Any] = None
5151

52+
default_headers: Optional[Dict[str, str]] = None
53+
default_query: Optional[Dict[str, Any]] = None
54+
5255
client: Optional[AzureOpenAIClient] = None
5356
async_client: Optional[AsyncAzureOpenAIClient] = None
5457

@@ -69,7 +72,11 @@ def _get_client_params(self) -> Dict[str, Any]:
6972
"azure_ad_token_provider": self.azure_ad_token_provider,
7073
"http_client": self.http_client,
7174
}
72-
75+
if self.default_headers is not None:
76+
_client_params["default_headers"] = self.default_headers
77+
if self.default_query is not None:
78+
_client_params["default_query"] = self.default_query
79+
7380
_client_params.update({k: v for k, v in params_mapping.items() if v is not None})
7481
if self.client_params:
7582
_client_params.update(self.client_params)

libs/agno/agno/playground/playground.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ def __init__(
3636

3737
if self.agents:
3838
for agent in self.agents:
39-
if not agent.agent_id:
40-
agent.agent_id = generate_id(agent.name)
39+
agent.initialize_agent()
4140

4241
if self.teams:
4342
for team in self.teams:
44-
if not team.team_id:
45-
team.team_id = generate_id(team.name)
43+
team.initialize_team()
44+
for member in team.members:
45+
if isinstance(member, Agent):
46+
member.initialize_agent()
47+
elif isinstance(member, Team):
48+
member.initialize_team()
4649

4750
if self.workflows:
4851
for workflow in self.workflows:

0 commit comments

Comments
 (0)