Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Fix] - Agent Delegation Tools Not Being Updated #1554

Conversation

c0dezli
Copy link
Contributor

@c0dezli c0dezli commented Nov 2, 2024

Problem

When an agent is marked with allow_delegation=True and have other tools assigned to it, it cannot access delegation tools. This occurs because the current implementation of _add_delegation_tools only updates task.tools but not agent.tools, causing the agent to lose access to delegation capabilities.

Solution

Updated _add_delegation_tools to properly manage both task.tools and agent.tools, ensuring delegation tools are correctly assigned and accessible.

Minimal Reproducible Example

from crewai import Agent, Crew, Task

# Create a simple tool
class SimpleTool:
    name = "simple_tool"
    def __call__(self): pass

# Setup agents
master_agent = Agent(
    name="master",
    tools=[SimpleTool()],
    allow_delegation=True  # This agent should be able to delegate
)

worker_agent = Agent(
    name="worker",
    tools=[SimpleTool()]
)

# Create crew
crew = Crew(
    agents=[master_agent, worker_agent],
    tasks=[Task(
        description="Test task",
        agent=master_agent
    )]
)

# Before fix: master_agent cannot access delegation tools
# After fix: master_agent can properly access delegation tools

Details

  • The bug was in crew.py's _add_delegation_tools method
  • Previously, delegation tools were only added to task.tools
  • Fixed by introducing add_or_update_tools helper function to manage tool lists
  • Now updates both agent.tools and task.tools

Testing

To verify the fix:

  1. Create a crew with multiple agents
  2. Set allow_delegation=True on the master agent
  3. Confirm the master agent can access and use delegation tools

Breaking Changes

None. This is a bug fix that maintains existing API compatibility.

@c0dezli c0dezli closed this Nov 3, 2024
@c0dezli c0dezli deleted the fix/allow-delegation-agent-cannot-have-other-tools branch November 3, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants