Update call_subordinate.py
frdel committed
Aug 12, 2025 at 14:34 UTC
d5fc0a32e79891b634cdb105c33a20def2ed45bb
1 file changed
+12
-9
python/tools/call_subordinate.py
+12
-9
@@ -1,6 +1,6 @@
1
from agent import Agent, UserMessage
2
from python.helpers.tool import Tool, Response
3
-import copy
3
+from initialize import initialize_agent
4
5
6
class Delegation(Tool):
@@ -11,22 +11,25 @@ class Delegation(Tool):
11
self.agent.get_data(Agent.DATA_NAME_SUBORDINATE) is None
12
or str(reset).lower().strip() == "true"
13
):
14
+ # initialize default config
15
+ config = initialize_agent()
16
+
17
+ # set subordinate prompt profile if provided, if not, keep original
18
+ agent_profile = kwargs.get("profile")
19
+ if agent_profile:
20
+ config.profile = agent_profile
21
+
22
# crate agent
15
- sub = Agent(self.agent.number + 1, copy.deepcopy(self.agent.config), self.agent.context)
23
+ sub = Agent(self.agent.number + 1, config, self.agent.context)
24
# register superior/subordinate
25
sub.set_data(Agent.DATA_NAME_SUPERIOR, self.agent)
26
self.agent.set_data(Agent.DATA_NAME_SUBORDINATE, sub)
19
- # set default prompt profile to new agents
20
- sub.config.profile = ""
27
28
# add user message to subordinate agent
23
- subordinate: Agent = self.agent.get_data(Agent.DATA_NAME_SUBORDINATE)
29
+ subordinate: Agent = self.agent.get_data(Agent.DATA_NAME_SUBORDINATE) # type: ignore
30
subordinate.hist_add_user_message(UserMessage(message=message, attachments=[]))
31
26
- # set subordinate prompt profile if provided, if not, keep original
27
- agent_profile = kwargs.get("profile")
28
- if agent_profile:
29
- subordinate.config.profile = agent_profile
32
+
33
34
# run subordinate monologue
35
result = await subordinate.monologue()