-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Implement A2A protocol support for recursive agent invocation #2901
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
base: main
Are you sure you want to change the base?
Conversation
- Modified BaseAgentTool._execute to accept and pass tools parameter - Updated DelegateWorkTool and AskQuestionTool to pass agent tools - Modified AgentTools to inject tools into delegation tools - Added test cases to verify recursive agent invocation works Fixes #2900 Co-Authored-By: Joe Moura <joao@crewai.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Disclaimer: This review was made by a crew of AI Agents. Code Review Comment: A2A Protocol ImplementationOverviewThe implementation of the Agent-to-Agent (A2A) protocol enhances recursive agent invocation by modifying the tool execution chain. This adjustment promotes better flexibility in agent communication and delegation. Overall, the changes reflect an understanding of the core principles of tool management within an agent framework. Strengths
Areas for Improvement1. Type HintingExplicitly identify types for the delegate_tool._agent_tools: List[BaseTool] = self._get_all_agent_tools() Adding type hints not only improves readability but also helps in maintaining type checks across the implementation. 2. Deduplication LogicThe seen_tools = set()
unique_tools = []
for agent in self.agents:
if agent.tools:
for tool in agent.tools:
tool_id = id(tool)
if tool_id not in seen_tools:
seen_tools.add(tool_id)
unique_tools.append(tool) 3. Consistent Tool RetrievalStandardize the retrieval of tools across different modules (e.g., def _get_tools(self, **kwargs) -> Optional[List[BaseTool]]:
"""Get tools from instance or kwargs."""
return getattr(self, '_agent_tools', None) or kwargs.get('tools') 4. Validation ChecksEnhance the code by including validation for the if tools is not None and not all(isinstance(tool, BaseTool) for tool in tools):
raise ValueError("All tools must inherit from BaseTool") 5. Logging EnhancementsAdd logging to observe the execution of tasks with tools, which will aid in debugging and monitoring tool usage: logger.debug(f"Executing task with {len(tools) if tools else 0} tools") 6. Test Enhancements
General Recommendations
Security Considerations
In summary, the implementation is sound with solid foundations. However, the suggested improvements will contribute significantly to code quality, maintainability, and robustness. Addressing these will lead to a more reliable system capable of handling the complexities of the Agent-to-Agent protocol. |
- Remove unused imports and variables in test files - Replace bare except with specific exception in structured_output_converter.py - Fix None comparison in llm_test.py - Update agent.execute_task to accept recursion_depth parameter Resolves all remaining lint issues for A2A protocol implementation. Co-Authored-By: Joe Moura <joao@crewai.com>
…ariables Co-Authored-By: Joe Moura <joao@crewai.com>
- Add tool deduplication logic in agent_tools.py - Re-implement recursion depth limits and validation in base_agent_tools.py - Add proper type hinting for _agent_tools attributes - Add consistent tool retrieval method across delegation tools - Enhance logging for debugging recursive agent invocations Addresses all remaining PR review comments for full A2A protocol support. Co-Authored-By: Joe Moura <joao@crewai.com>
Co-Authored-By: Joe Moura <joao@crewai.com>
- Update BaseAgent.execute_task signature to include recursion_depth parameter - Fix variable reference in base_agent_tools.py (agent -> matching_agents) - Remove type annotations in assignment to non-self attributes in agent_tools.py Co-Authored-By: Joe Moura <joao@crewai.com>
Co-Authored-By: Joe Moura <joao@crewai.com>
Co-Authored-By: Joe Moura <joao@crewai.com>
- Remove race condition in FilteredStream.write() method - Remove class-level _lock = None that caused threading issues - Ensures proper lock initialization in __init__ only Fixes Python 3.10 CI test failures with exit code 139 Co-Authored-By: Joe Moura <joao@crewai.com>
Implement A2A protocol support for recursive agent invocation
Description
This PR implements full A2A (Agent-to-Agent) protocol support in CrewAI by enabling recursive agent invocation. Previously, when an agent was invoked by another agent through delegation tools, the invoked agent couldn't recursively invoke other agents because tools weren't preserved during the delegation process.
Changes
BaseAgentTool._execute
to accept and pass tools parameterDelegateWorkTool
andAskQuestionTool
to pass agent toolsAgentTools
to inject tools into delegation toolsTesting
Related Issues
Fixes #2900
Link to Devin run
https://app.devin.ai/sessions/3259726787a8459cb24632ab74e549e9
Requested by
Joe Moura (joao@crewai.com)