File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def client(self) -> ModelClient:
8585 async def _update_swarm_agent (self ) -> None :
8686 agent_names = list (self ._sub_agents .keys ())
8787 logger .debug (
88- f"[{ self .__class__ .__name__ } ] Discovered sub-agents: { agent_names } "
88+ f"[{ self .__class__ .__name__ } { self . id } ] Discovered sub-agents: { agent_names } "
8989 )
9090
9191 tools = []
Original file line number Diff line number Diff line change @@ -131,6 +131,13 @@ def __init__(self, timeout: float = 60):
131131 ** message_types ,
132132 }
133133
134+ @property
135+ def id (self ) -> str :
136+ if self .address .id :
137+ return f"{ self .address .name } .{ self .address .id } "
138+ else :
139+ return self .address .name
140+
134141 def init (self , channel : Channel , address : Address ) -> None :
135142 self .channel = channel
136143 self .address = address
@@ -171,9 +178,8 @@ async def stopped(self) -> None:
171178 pass
172179
173180 async def receive (self , raw : RawMessage ) -> None :
174- logger .debug (
175- f"[{ self .__class__ .__name__ } ] Received a message: { raw .model_dump ()} "
176- )
181+ name : str = f"{ self .__class__ .__name__ } { self .id } "
182+ logger .debug (f"[{ name } ] Received a message: { raw .model_dump ()} " )
177183
178184 async with self ._lock :
179185 self ._last_msg_received_at = time .time ()
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ async def _recycle(self) -> None:
9494
9595 running_num = total_num - idle_num
9696 logger .debug (
97- f"[Factory { self .address . name } ] Recycling agents: { running_num } running, { idle_num } idle"
97+ f"[Factory { self .id } ] Recycling agents: { running_num } running, { idle_num } idle"
9898 )
9999
100100 deleted_agents : list [Agent ] = []
Original file line number Diff line number Diff line change @@ -136,6 +136,12 @@ class State(str, enum.Enum):
136136
137137
138138class Agent (abc .ABC ):
139+ @property
140+ @abc .abstractmethod
141+ def id (self ) -> str :
142+ """Return the unique ID of the agent."""
143+ pass
144+
139145 @abc .abstractmethod
140146 def init (self , channel : Channel , address : Address ) -> None :
141147 """Initialize the agent with the given channel and address."""
You can’t perform that action at this time.
0 commit comments