VRSEN / agency-swarm

The only reliable agent framework built on top of the latest OpenAI Assistants API.
https://vrsen.github.io/agency-swarm/
MIT License
2.42k stars 650 forks source link

Agent.tools should clone the tools array #23

Closed birdperson1970 closed 9 months ago

birdperson1970 commented 9 months ago

Here is my code snippet:

tools.append(GoogleSearchTool)
tools.append(ShellTool)
tools.append(GitHubTool)

agent_po = Agent(name="agent-po",
            tools=tools)

agent_arch = Agent(name="agent-architect",
            tools=tools)

agent_dev = Agent(name="agent-developer",
            tools=tools)

But when I tried to get them to communicate I got:

👤 User: say hello to the developer

SendMessage(
{"chain_of_thought":"User has requested to send a greeting to the developer. The task at hand simply involves conveying a friendly message from the user to the developer. The appropriate response would be to acknowledge the user's greeting and deliver it to the developer.","recipient":"agent-developer","message":"Hello from the user!"})
)
Error: 1 validation error for SendMessage recipient Input should be 'agent-architect' [type=enum, input_value='agent-developer', input_type=str]

After much debugging I identified this was because they shared the same tools array. The Agent was updating it to add the SendMessage function and this resulted in the above error.

I will submit a pull request for Agent.init() self.tools = tools[:] if tools is not None else []

Hopefully this will save others some time...

VRSEN commented 9 months ago

Thank you