Files
crewAI/examples/a2a_integration_example.py
Devin AI 78b9c7dbeb feat: Add A2A (Agent-to-Agent) protocol support for remote interoperability
- Implement CrewAgentExecutor class that wraps CrewAI crews as A2A-compatible agents
- Add server utilities for starting A2A servers with crews
- Include comprehensive test coverage for all A2A functionality
- Add optional dependency group 'a2a' in pyproject.toml
- Expose A2A classes in main CrewAI module with graceful import handling
- Add documentation and examples for A2A integration
- Support bidirectional agent communication via A2A protocol
- Enable crews to participate in remote agent networks

Fixes #2970

Co-Authored-By: João <joao@crewai.com>
2025-06-06 23:34:27 +00:00

65 lines
1.8 KiB
Python

"""Example: CrewAI A2A Integration
This example demonstrates how to expose a CrewAI crew as an A2A (Agent-to-Agent)
protocol server for remote interoperability.
Requirements:
pip install crewai[a2a]
"""
from crewai import Agent, Crew, Task
from crewai.a2a import CrewAgentExecutor, start_a2a_server
def main():
"""Create and start an A2A server with a CrewAI crew."""
researcher = Agent(
role="Research Analyst",
goal="Provide comprehensive research and analysis on any topic",
backstory=(
"You are an experienced research analyst with expertise in "
"gathering, analyzing, and synthesizing information from various sources."
),
verbose=True
)
research_task = Task(
description=(
"Research and analyze the topic: {query}\n"
"Provide a comprehensive overview including:\n"
"- Key concepts and definitions\n"
"- Current trends and developments\n"
"- Important considerations\n"
"- Relevant examples or case studies"
),
agent=researcher,
expected_output="A detailed research report with analysis and insights"
)
research_crew = Crew(
agents=[researcher],
tasks=[research_task],
verbose=True
)
executor = CrewAgentExecutor(
crew=research_crew,
supported_content_types=['text', 'text/plain', 'application/json']
)
print("Starting A2A server with CrewAI research crew...")
print("Server will be available at http://localhost:10001")
print("Use the A2A CLI or SDK to interact with the crew remotely")
start_a2a_server(
executor,
host="0.0.0.0",
port=10001,
transport="starlette"
)
if __name__ == "__main__":
main()