DEV Community

Ade Adebayo
Ade Adebayo

Posted on

Building a Production-Ready A2A Protocol Agent: A Technical Journey

So, this week came with a new challenge, tasking but interesting. This document chronicles the development of a simple A2A (Agent-to-Agent) Protocol agent built with Python and FastAPI. The agent monitors package dependencies for security vulnerabilities, providing both conversational (Telex) and RESTful interfaces.

Package Health Monitor Agent is an A2A (Agent-to-Agent) Protocol AI Agent built with Python and FastAPI that monitors package dependencies for security vulnerabilities, outdated versions, and deprecated packages. It was designed for Telex integration with natural language processing capabilities.

Its features include: A2A Protocol Support, Multi-Language Support, Security Scanning, Health Scoring, Smart Recommendations, Natural Language and RESTful API with traditional REST endpoints for direct integration

The Problem
This project was carried out as part of the HNG stage tasks. However, modern software projects depend on dozens, sometimes hundreds, of third-party packages. These dependencies can become outdated, vulnerable or deprecated, and developers need a quick, conversational way to check their dependencies' health without context-switching between multiple websites and tools.

This problem led to building this AI agent that:

  1. Accepts natural language queries ("Check flask==2.0.1, requests==2.25.0")
  2. Analyzes packages across multiple ecosystems (Python/PyPI, JavaScript/npm)
  3. Checks real-time vulnerability databases (OSV)
  4. Provides actionable recommendations
  5. Integrates with Telex for conversational workflows

Core Components

  1. FastAPI Application (main_a2a.py)
  2. Modern async web framework
  3. Automatic OpenAPI documentation
  4. Native Pydantic integration for validation

  5. Data Models (models/)

  6. a2a.py - A2A Protocol models (messages, requests, responses)

  7. schemas.py - API request/response models

  8. A2A Handler (a2a_handler.py)

  9. Message processing logic

  10. Natural language parsing

  11. Package analysis orchestration

  12. Package Checker
    Integration with external APIs:

  13. PyPI - Python Package Index (https://pypi.org/pypi/{package}/json)

  14. npm - Node Package Manager (https://registry.npmjs.org/{package})

  15. OSV - Open Source Vulnerabilities (https://api.osv.dev/v1/query)

  16. A2A Handler (a2a_handler.py)

  17. Message processing logic

  18. Natural language parsing

  19. Package analysis orchestration

  20. Package Checker
    Integration with external APIs:

  21. PyPI - Python Package Index (https://pypi.org/pypi/{package}/json)

  22. npm - Node Package Manager (https://registry.npmjs.org/{package})

  23. OSV - Open Source Vulnerabilities (https://api.osv.dev/v1/query)

Live API: https://packagehealthmonitoragent-2367cacc569a.herokuapp.com/

Documentation: https://packagehealthmonitoragent-2367cacc569a.herokuapp.com/docs


**Technical Stack*

Core Technologies

Technology Version Purpose
Python 3.13 Runtime with improved performance
FastAPI 0.115.5 Async web framework
Pydantic 2.10.3 Data validation with strict typing
Uvicorn 0.32.1 ASGI server for production
Requests 2.32.3 HTTP client for external APIs

External APIs

  • PyPI JSON API - https://pypi.org/pypi/{package}/json
  • npm Registry - https://registry.npmjs.org/{package}
  • OSV Database - https://api.osv.dev/v1/query

Development Tools

  • Git/GitHub - Version control
  • Heroku - PaaS deployment
  • Postman - API testing
  • VS Code - Development environment

Performance Characteristics

Response Times (Average)

  • /health - <10ms (no external calls)
  • /check-package - 150-300ms (2 external API calls)
  • /analyze/python - 500ms-2s (N packages × 2 API calls each)
  • /a2a - 200ms-2s (depends on message complexity)

Scalability Considerations

Current Limitations:

  • Sequential package checking (no parallelization)
  • No caching of PyPI/npm responses
  • No rate limiting on external APIs

Future Improvements:

  • Use asyncio.gather() for parallel package checks
  • Implement Redis cache for package metadata
  • Add rate limiting with exponential backoff

Code Statistics

Language                 Files        Lines         Code     Comments
────────────────────────────────────────────────────────────────────
Python                       4          850          650          100
Markdown                     2          650          550           50
TOML                         1           20           18            2
Text                         2           15           15            0
────────────────────────────────────────────────────────────────────
Total                        9         1535         1233          152
Enter fullscreen mode Exit fullscreen mode

Test Coverage

  • A2A Protocol: Tested
  • Python Package Analysis: Tested
  • npm Package Analysis: Tested
  • Error Handling: Tested
  • Edge Cases: Tested

Resources & References

Documentation

Helpful Articles

  • "Type Hints in Python" - Real Python
  • "Building Production-Ready APIs" - FastAPI Best Practices
  • "Protocol Design Patterns" - Martin Fowler

Tools Used

Conclusion

Building this Package Health Monitor Agent was a journey from simple REST API to enterprise-grade A2A protocol implementation. The key insights:

  1. Start Simple, Refactor Thoughtfully - The initial flexible approach taught us what we needed before committing to strict types.

  2. Protocol Compliance Matters - Proper JSON-RPC 2.0 error codes make debugging integration issues 10x easier.

  3. Type Safety is Worth It - Strict Literal types caught bugs before they reached production.

  4. Production is Different - Logging, error handling, and documentation separate hobby projects from professional tools.

  5. Iterate Based on Real Use - The Telex integration exposed assumptions we didn't know we had.

The agent now serves as a production-ready example of:

  • Modern Python API development with FastAPI
  • A2A Protocol implementation best practices
  • Type-safe protocol design with Pydantic
  • Professional DevOps practices with Heroku

Live Demo: Try it at https://packagehealthmonitoragent-2367cacc569a.herokuapp.com/docs

Source Code: https://github.com/MyITjournal/package-health-agent

Want to build your own A2A agent? Clone this repo and use it as a starting template! All code is MIT licensed.

Questions or suggestions? Open an issue on GitHub or connect with me at @MyITjournal.

Author: Adeyoola Adebayo
Project: Package Health Monitor Agent

Live API: https://packagehealthmonitoragent-2367cacc569a.herokuapp.com/

Top comments (0)