Skip to content

Commit

Permalink
Merge pull request #16 from ServiceNow/rename-manager
Browse files Browse the repository at this point in the history
Rename Agent._boss -> Agent._manager
  • Loading branch information
jpt-sn authored Sep 23, 2024
2 parents d689121 + 97af553 commit 8e1816c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions tapeagents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Agent(BaseModel, Generic[TapeType]):
)
max_iterations: int = 100

_boss: Any | None = None
_manager: Any | None = None

model_config = ConfigDict(extra="forbid")

Expand All @@ -138,20 +138,20 @@ def model_post_init(self, __context: Any) -> None:
for agent in self.subagents:
names.add(agent.name)
if isinstance(agent, Agent):
if agent._boss is not None:
if agent._manager is not None:
raise ValueError("Agent is already a subagent of another agent. Make a copy of your agent.")
agent._boss = self
agent._manager = self
else:
raise ValueError("Subagents must be instances of Agent")
if len(names) < len(self.subagents):
raise ValueError("Subagents have duplicate names")
return super().model_post_init(__context)

@property
def boss(self):
if self._boss is None:
raise ValueError("Agent doesn't have a boss")
return self._boss
def manager(self):
if self._manager is None:
raise ValueError("Agent doesn't have a manager")
return self._manager

@property
def llm(self):
Expand All @@ -167,9 +167,9 @@ def template(self):

@property
def full_name(self):
if self._boss is None:
if self._manager is None:
return self.name
return f"{self._boss.full_name}/{self.name}"
return f"{self._manager.full_name}/{self.name}"

def find_subagent(self, name: str):
for agent in self.subagents:
Expand Down
2 changes: 1 addition & 1 deletion tapeagents/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def render_agent_tree(agent: Agent):
Like this:
- Big Boss
- The Manager
- His Assistant 1
- His Helper 2
Expand Down
2 changes: 1 addition & 1 deletion tapeagents/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def pop_view_from_stack(self, step):
new_top.outputs_by_subagent[top.agent_name] = top_step
break

# TODO: what if the agent was not called by its immediate boss?
# TODO: what if the agent was not called by its immediate manager?
receiver = step.by.rsplit("/", 1)[0]
self.messages_by_agent[step.by].append(step)
self.messages_by_agent[receiver].append(step)
Expand Down

0 comments on commit 8e1816c

Please sign in to comment.