mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
Fixes #3899 The issue was that when a remote A2A agent responded with status 'completed', the server agent was ignoring it and delegating the same request again. This caused an infinite loop until max_turns was reached. The root cause was in _delegate_to_a2a() where both 'completed' and 'input_required' statuses were handled identically. The code would call _handle_agent_response_and_continue() which could return (None, next_request), causing the loop to continue even though the remote agent said it was completed. The fix differentiates between the two statuses: - 'completed': Extract the final message from the a2a_result or conversation history and return immediately without consulting the LLM again - 'input_required': Continue with the existing behavior of consulting the LLM for next steps Added comprehensive tests to verify: 1. Delegation stops immediately on 'completed' status 2. Delegation continues properly on 'input_required' status 3. Empty history with 'completed' status is handled gracefully 4. Final message is extracted from history when result is empty Co-Authored-By: João <joao@crewai.com>