allow_delegation=True leading to infinite loop
I'm trying the demo code for crewAI. I've observed when using allow_delegation with any agent (writer in case of demo code), the execution goes in an infinite loop. When false, the execution completes but the writer agent wont be able to delegate tasks to others.
Have you tried https://docs.crewai.com/how-to/Hierarchical/ and allow the manager to the delegation?
In my case I did 3 agents (researcher, writer, critic reviewer) and all with delegation=true, but there was no loop, they did use their max iterations though in order to come to conclusion of answer to pass to next agent. not sure at what point the agent makes decision that enough iteration was completed and it's time to pass results to next one, but I had no loop as you describe, maybe it was fixed in the last version or smth, worth a try
I tried the hierarchical process (had a manager_llm) but it still went into infinite loop.
I have the same issue
same issue here
Here is an example of a simple addition tool being used in a hierarchical setup: Please enter the math task (e.g., '5 plus 3', 'ten minus four'): six plus 2 2024-09-14 12:36:05,556 - 14460 - init.py-init:1236 - WARNING: SDK is disabled. [2024-09-14 12:36:05][INFO]: Planning the crew execution 2024-09-14 12:36:05,574 - 14460 - init.py-init:1236 - WARNING: SDK is disabled. Error parsing JSON: Expecting value: line 1 column 1 (char 0). Attempting to handle partial JSON. [2024-09-14 12:36:22][DEBUG]: == Working Agent: Crew Manager [2024-09-14 12:36:22][INFO]: == Starting Task: six plus 2Step 1: Identify the task The task at hand is to calculate the result of 'six plus 2'.
Step 2: Assign an agent Since this is a simple mathematical calculation, no specific agent needs to be assigned. The task can be completed by any available agent.
Step 3: Gather necessary tools No special tools are required for this task. Basic arithmetic knowledge and mental math skills will suffice.
Step 4: Execute the task Follow these steps to perform the calculation: a) Identify the numbers involved - in this case, 6 and 2. b) Recall or apply basic addition rules to add the two numbers together. c) Perform the addition mentally or on paper (if desired). d) Arrive at the sum.
Step 5: Verify the result Double-check the calculation to ensure accuracy. The expected output is a numerical answer, which should be confirmed before proceeding.
Step 6: Document the outcome Record the final result of the task for reference and future use.
Step 7: Review and optimize Evaluate the agent's performance in completing this task. If any areas for improvement are identified, consider incorporating them into future calculations or similar tasks to enhance efficiency and accuracy. 2024-09-14 12:36:22,584 - 14460 - init.py-init:1236 - WARNING: SDK is disabled.
Entering new CrewAgentExecutor chain... Action: Delegate work to coworker Action Input: {'task': 'Calculate 6 plus 2', 'context': "I need you to perform a simple addition calculation. The numbers involved are 6 and 2. Please add these two numbers together and provide the sum as your final answer.", 'coworker': 'Addition Specialist
Entering new CrewAgentExecutor chain... Action: Addition Tool Action Input: {"a": 6, "b": 2
8
2024-09-14 12:36:25,821 - 14460 - init.py-init:1236 - WARNING: SDK is disabled. Final Answer: I have calculated the sum of 6 and 2 using the Addition Tool. The result is 8. This is the correct answer to your simple addition problem. Please let me know if you need any further assistance with calculations.
Finished chain.
I have calculated the sum of 6 and 2 using the Addition Tool. The result is 8. This is the correct answer to your simple addition problem. Please let me know if you need any further assistance with calculations.
2024-09-14 12:36:27,160 - 14460 - init.py-init:1236 - WARNING: SDK is disabled. Thought: Action: Ask question to coworker Action Input: {'question': 'Is 8 the correct sum for adding 6 and 2?', 'context': "I have received an answer of 8 from my Addition Specialist when calculating the sum of 6 and 2. I need confirmation that this is indeed the correct result.", 'coworker': 'Addition Specialist
Entering new CrewAgentExecutor chain... Action: Addition Tool Action Input: {"a": 6, "b": 2
8
2024-09-14 12:36:30,691 - 14460 - init.py-init:1236 - WARNING: SDK is disabled. Thought: I have received an answer of 8 from my Addition Specialist when calculating the sum of 6 and 2. I need confirmation that this is indeed the correct result.
The Addition Tool was used correctly with the inputs 6 and 2, and it returned a result of 8. This matches the expected sum of these two numbers.
Final Answer: Yes, the Addition Specialist calculated the sum of 6 and 2 correctly. The result is indeed 8. The tool performed the addition accurately as intended.
Finished chain.
Yes, the Addition Specialist calculated the sum of 6 and 2 correctly. The result is indeed 8. The tool performed the addition accurately as intended.
As you can see the execution succeeds, but the chain doesn't stop and the manager continues. I already tried setting temperature to 0.1, but this doesn't help.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
I had this issue again today. Can we get someone to look into this?
@donutranger, were you able to help with this issue? I have been having the same issue
Still facing this issue