This project demonstrates and validates the hypothesis:
"The use of the Agent2Agent (A2A) protocol enables more efficient and autonomous coordination between agents in practical scenarios, compared to ad-hoc agent communication implementations."
We implement a multi-agent system for code review and PR management, where each agent has a specialized role and coordination is handled via the A2A protocol.
src/
├── agents/ # SPADE agent implementations
├── coordinator/ # Coordinator logic
├── tasks/ # Task and artifact utilities
├── utils/ # Helper utilities
└── main.py # Entry point
- Docker (for Prosody XMPP server)
- Python 3.8+ (recommended: 3.10+)
- pip
git clone <repo-url>
cd <repo-folder>
docker run -d --name prosody -p 5222:5222 -p 5280:5280 prosody/prosody
docker exec -it prosody sh
# Inside the container:
echo 'c2s_require_encryption = false' >> /etc/prosody/prosody.cfg.lua
exit
docker restart prosody
docker exec -it prosody prosodyctl adduser pr@localhost
# (set password, e.g. prpassword)
docker exec -it prosody prosodyctl adduser best@localhost
# (set password, e.g. bestpassword)
docker exec -it prosody prosodyctl adduser vuln@localhost
# (set password, e.g. vulnpassword)
docker exec -it prosody prosodyctl adduser merge@localhost
# (set password, e.g. mergepassword)
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Edit src/coordinator/coordinator.py
and ensure the agent JIDs and passwords match those you set above.
python3 src/main.py
- The final combined report is saved as
a2a_report.json
in the project root. - You can open this file with any text editor or JSON viewer.
- PullRequestAgent: Simulates PR creation.
- BestPracticesAgent: Reviews code style and best practices.
- VulnerabilityAgent: Scans for security issues.
- MergeAgent: Attempts to merge if all checks pass.
- Coordinator: Orchestrates the workflow using the A2A protocol.
All communication and task assignment between agents follows the A2A protocol, with structured JSON messages, agent cards, and task artifacts.
To validate the hypothesis, you can:
-
Run this project (A2A protocol) and measure:
- Time to complete the workflow
- Number of lines of code for coordination
- Autonomy (no hardcoded agent logic, agents are discoverable and tasks are structured)
- Robustness (easy to add new agents or change workflow)
-
Run the ad-hoc version (agents communicate via direct function calls, global variables, or unstructured messages) and compare:
- Code complexity and maintainability
- Flexibility to add/replace agents
- Error handling and extensibility
- How easy it is to change the workflow
Expected result:
- The A2A protocol version will be more modular, easier to extend, and require less manual intervention for agent coordination, validating the hypothesis.
-
A2A (SPADE/XMPP):
python3 src/main.py
This will generate the file
a2a_report.json
. -
Ad-hoc:
python3 src/main_adhoc.py
This will generate the file
adhoc_report.json
.
- Run the comparison script:
This will display a summary table and a bar chart comparing the execution times of each workflow stage.
python3 compare_reports.py
To use the comparison and visualization script (compare_reports.py
), you need to install two additional Python packages:
- Activate your virtual environment (if not already active):
source venv/bin/activate
- Install the required packages:
pip install tabulate matplotlib
Now you can run the comparison script as described above:
python3 compare_reports.py
This will display a summary table and a bar chart comparing the execution times of each workflow stage.
- Analysis results: Both workflows should produce the same linting and vulnerability reports if they use the same input.
- Timing: The ad-hoc version is usually faster, but the A2A version is more modular and extensible.
- Modularity and autonomy: The A2A approach allows for independent agents and structured communication, ideal for distributed or scalable scenarios.
- Use A2A if you need autonomy, extensibility, or distributed agents.
- Use ad-hoc if you only care about speed and simplicity in a controlled environment.
For any issues or questions, open an issue or contact the maintainer.