Skip to content

Commit da114e6

Browse files
committed
update
1 parent e39b2f2 commit da114e6

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

cookbook/agent_os/handle_custom_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from typing import Optional
1010

1111
from agno.agent import Agent
12-
from agno.team import Team
1312
from agno.db.postgres import PostgresDb
1413
from agno.os import AgentOS
1514
from agno.run.agent import CustomEvent
15+
from agno.team import Team
1616

1717
# Setup the database
1818
db = PostgresDb(id="basic-db", db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")
@@ -93,4 +93,4 @@ async def get_customer_profile(session_state: dict):
9393
--data-urlencode 'user_id=user_123.' \
9494
--data-urlencode 'session_state={"customer_name": "John Doe", "customer_email": "john.doe@example.com", "customer_phone": "1234567890"}'
9595
"""
96-
agent_os.serve(app="handle_custom_events:app", reload=True)
96+
agent_os.serve(app="handle_custom_events:app", reload=True)

libs/agno/agno/run/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class OutputModelResponseCompletedEvent(BaseAgentRunEvent):
384384
@dataclass
385385
class CustomEvent(BaseAgentRunEvent):
386386
event: str = RunEvent.custom_event.value
387-
387+
388388
def __init__(self, **kwargs):
389389
# Store arbitrary attributes directly on the instance
390390
for key, value in kwargs.items():

libs/agno/agno/run/team.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,13 @@ class OutputModelResponseCompletedEvent(BaseTeamRunEvent):
367367
@dataclass
368368
class CustomEvent(BaseTeamRunEvent):
369369
event: str = TeamRunEvent.custom_event.value
370-
370+
371371
def __init__(self, **kwargs):
372372
# Store arbitrary attributes directly on the instance
373373
for key, value in kwargs.items():
374374
setattr(self, key, value)
375375

376376

377-
378377
TeamRunOutputEvent = Union[
379378
RunStartedEvent,
380379
RunContentEvent,

libs/agno/agno/run/workflow.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from pydantic import BaseModel
77

88
from agno.media import Audio, Image, Video
9-
from agno.run.agent import RunOutput, RunEvent, run_output_event_from_dict
9+
from agno.run.agent import RunEvent, RunOutput, run_output_event_from_dict
1010
from agno.run.base import BaseRunOutputEvent, RunStatus
11-
from agno.run.team import TeamRunOutput, TeamRunEvent, team_run_output_event_from_dict
11+
from agno.run.team import TeamRunEvent, TeamRunOutput, team_run_output_event_from_dict
1212

1313
if TYPE_CHECKING:
1414
from agno.workflow.types import StepOutput, WorkflowMetrics
@@ -394,7 +394,6 @@ def __init__(self, **kwargs):
394394
setattr(self, key, value)
395395

396396

397-
398397
# Union type for all workflow run response events
399398
WorkflowRunOutputEvent = Union[
400399
WorkflowStartedEvent,

libs/agno/agno/utils/message.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def filter_tool_calls(messages: List[Message], max_tool_calls: int) -> None:
2626
tool_call_ids_list: List[str] = []
2727
for msg in reversed(messages):
2828
if msg.role == "tool" and len(tool_call_ids_list) < max_tool_calls:
29-
if msg.tool_call_id:
30-
tool_call_ids_list.append(msg.tool_call_id)
29+
if msg.tool_call_id:
30+
tool_call_ids_list.append(msg.tool_call_id)
3131

3232
tool_call_ids_to_keep: set[str] = set(tool_call_ids_list)
3333

@@ -45,9 +45,7 @@ def filter_tool_calls(messages: List[Message], max_tool_calls: int) -> None:
4545
# Filter tool_calls
4646
if filtered_msg.tool_calls is not None:
4747
filtered_msg.tool_calls = [
48-
tc
49-
for tc in filtered_msg.tool_calls
50-
if tc.get("id") in tool_call_ids_to_keep
48+
tc for tc in filtered_msg.tool_calls if tc.get("id") in tool_call_ids_to_keep
5149
]
5250

5351
if filtered_msg.tool_calls:

0 commit comments

Comments
 (0)