crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Fix co-worker task delegation failure

Open charl3sj opened this issue 1 year ago • 6 comments

charl3sj avatar Jul 22 '24 05:07 charl3sj

Oh interesting, I was not aware of this, so this is to make sure the agent being delegated can use the tasks tools?

joaomdmoura avatar Jul 28 '24 18:07 joaomdmoura

The problem I was trying to fix is of AgentTools (Delegate work to coworker and Ask question to coworker) not being loaded because of being appended to the task in this method: https://github.com/crewAIInc/crewAI/blob/2fe79e68cde0067b56b8aaf5901cfa50f664238a/src/crewai/crew.py#L733 ... causing delegation to not work.

charl3sj avatar Jul 29 '24 02:07 charl3sj

After going through the docs and code again, I realized that delegation is meant for only hierarchical processes and I was trying delegation with a sequential process. That's why it didn't work. Feel free to close this PR if it's not a use-case you want to or makes sense to support.

charl3sj avatar Jul 29 '24 06:07 charl3sj

Oh it was supposed to work on sequential as well, I'll run some tests locally

joaomdmoura avatar Jul 30 '24 02:07 joaomdmoura

Just ran into this exact issue, the docs say that delegation should work for Sequential but I was never seeing coworkers being used.

Looking at the proposed change, I think it might read better if _prepare_agent_tools was removed which adds the delegation tasks to the task's tool list (which is a bit weird given allow_delegation is a property of an Agent not a task). Instead, we can move the manager tool setup into the if self.process == Process.hieracchical in _execute_tasks, and then for the Sequential case use the union logic to join task.agent.tools, task.tools, and task.agent.get_delegation_tools().

Tehsmash avatar Sep 26 '24 13:09 Tehsmash

Hey @charl3sj! Thanks so much for the pull request!

Could you take a moment to check if the changes are still valid? We've made quite a few updates since July. If they still apply, I’d be more than happy to help you get everything sorted and make it happen! 😊

pythonbyte avatar Dec 09 '24 14:12 pythonbyte