ADR-006: A2A Agent Generation Refactoring
Status
ACCEPTED ✅ Implemented
Context
The original mcp_codegen.py module had grown to over 1300 lines and was handling both MCP server generation and A2A (Agent-to-Agent) agent generation. This violated the single responsibility principle and made the codebase harder to maintain and test.
Problems Identified:
- Mixed Concerns: MCP server and A2A agent generation logic were intertwined
- Large File Size: 1315+ lines in a single module
- Testing Complexity: A2A generation couldn't be tested independently of MCP dependencies
- Integration Gaps: Missing integration with CNOE tooling (Agent Chat CLI)
- Development Workflow: Lack of standardized environment setup and testing procedures
User Request:
"move this to a2a_agent_codegen.py" + "Use https://github.com/cnoe-io/agent-chat-cli to test it, add it to the docs/docs in the setup guides"
Decision
We will refactor the A2A agent generation functionality into a separate module and create comprehensive documentation for testing with Agent Chat CLI.
Implementation Strategy:
-
Extract A2A Generation Logic:
- Move
generate_a2a_agent()and_generate_a2a_agent_files()frommcp_codegen.py - Create new
A2AAgentGeneratorclass ina2a_agent_codegen.py - Maintain backward compatibility in CLI interface
- Move
-
Enhance Development Workflow:
- Add
.envtemplate and setup automation - Create standardized Makefile targets
- Improve development experience with
make devshortcut
- Add
-
Comprehensive Documentation:
- Create detailed testing guide with Agent Chat CLI integration
- Add setup guides structure
- Include architecture diagrams and troubleshooting
-
CNOE Integration:
- Full integration with Agent Chat CLI
- Testing workflows and examples
- Performance monitoring and debugging procedures
Consequences
Positive:
- ✅ Separation of Concerns: Clean boundary between MCP and A2A generation
- ✅ Better Maintainability: Each component can evolve independently
- ✅ Improved Testability: A2A generation has isolated test coverage
- ✅ Enhanced Documentation: 400+ lines of comprehensive testing guides
- ✅ Professional Workflow: Standardized
.envsetup and make targets - ✅ CNOE Integration: Seamless integration with existing CNOE tooling
Architecture Changes:
Before (Monolithic):
mcp_codegen.py (1315 lines)
├── MCP server generation
├── A2A agent generation ← Mixed concerns
└── CLI integration
After (Separated):
mcp_codegen.py (1200 lines)
├── MCP server generation only
a2a_agent_codegen.py (300+ lines) ← NEW
├── A2AAgentGenerator class
├── Focused A2A agent generation
└── Clean, maintainable code
docs/docs/setup-guides/
├── index.md
└── testing-with-agent-chat-cli.md ← NEW
Complete Workflow Example:
- Generate A2A Agent:
uv run python -m openapi_mcp_codegen generate-a2a-agent \
--spec-file examples/argo-workflows/argo-openapi-enhanced-compliant.json \
--agent-name "argo_workflows" \
--mcp-server-url "http://localhost:3000"
- Setup Environment:
cd agent_argo_workflows
make dev # Creates .venv, .env, installs deps, formats code
- Start Agent:
make run-a2a # Starts A2A agent on localhost:8000
- Test with Agent Chat CLI:
git clone https://github.com/cnoe-io/agent-chat-cli.git
cd agent-chat-cli
uv sync
uv run python -m agent_chat_cli a2a --host localhost --port 8000
Metrics:
- Lines of Code Moved: ~150 lines from
mcp_codegen.pytoa2a_agent_codegen.py - New Documentation: 400+ lines in comprehensive testing guide
- New Features:
.envgeneration, make targets, dry-run support - Integration Points: Full Agent Chat CLI integration with examples
- Test Coverage: Multiple testing scenarios and debugging procedures
Risk Mitigation:
- Backward Compatibility: All existing CLI commands continue to work unchanged
- Incremental Migration: Changes can be rolled back without breaking existing workflows
- Comprehensive Testing: Multiple testing scenarios documented and validated
Implementation Status
COMPLETED ✅
All requested functionality has been implemented:
- ✅ A2A agent generation moved to separate file (
a2a_agent_codegen.py) - ✅ Agent Chat CLI integration documented in
docs/docs/setup-guides/ - ✅ Setup guides added with comprehensive testing procedures
- ✅ Enhanced with professional development workflow (
.env, Makefile targets) - ✅ Complete testing and troubleshooting documentation
The refactoring successfully achieves better code organization, improved maintainability, and seamless integration with CNOE tooling ecosystem.