Agent-to-Agent (A2A) Protocol featuring an AI-powered weather agent with a unique Azerbaijani cultural personality, powered by Azure OpenAI and modern TypeScript tooling.
This project showcases a production-ready implementation of agent-to-agent communication, combining multiple technologies into a cohesive, event-driven architecture. Demonstration of how AI agents can communicate using standardised protocols whilst having their own tools independently.
- Protocol-Compliant Communication: Full implementation of the Agent-to-Agent protocol v0.3.0
- Agent Card Discovery: Exposes agent capabilities via
.well-known/agent-card.jsonendpoint - Multi-Part Message Handling: Sophisticated message parsing supporting multiple content types
- Event-Driven Architecture: Uses
ExecutionEventBusfor asynchronous message processing
- Agentic Workflows: Leverages the
@openai/agentsSDK for autonomous decision-making - Tool Chaining: Dynamically chains multiple tools (weather fetching โ personality transformation)
- Azure OpenAI: Production-grade integration with Azure's OpenAI service
- Zod Schema Validation: Type-safe parameter validation for all tool inputs
- Weather Tool: Real-time weather data from WeatherAPI.com
- Qedeshator Tool: Cultural personality injection using GPT-4, transforming responses into authentic Azerbaijani street slang
The agent features a unique Azerbaijani qษdeล persona that:
- Speaks in po-bratski style with authentic dialect
- Uses culturally-specific phrases
- Employs grammatical patterns specific to Yasamal street culture
- Maintains character consistency through system prompt engineering
- Client-Server Separation: Clean separation of concerns with dedicated client and server implementations
- In-Memory Task Store: Efficient task tracking with
InMemoryTaskStore - UUID-Based Message Tracking: Ensures message traceability and idempotency
- Express 5.x Integration: Modern Express setup with type-safe routing via
A2AExpressApp - TypeScript + ESM: Full TypeScript with ES modules for modern JavaScript features
| Technology | Purpose | Why It's Cool |
|---|---|---|
| @a2a-js/sdk | Agent-to-Agent protocol | Standardised agent communication, future-proofing AI interoperability |
| @openai/agents | Agentic AI framework | Autonomous tool selection and execution |
| Azure OpenAI | LLM inference | Enterprise-grade AI with GPT-4 |
| TypeScript | Type safety | Catch errors at compile-time, not runtime |
| Zod | Schema validation | Runtime type safety for API boundaries |
| Express 5.x | Web server | Latest Express with improved async/await support |
| WeatherAPI.com | Weather data | Real-time weather information |
| dotenv | Configuration | Secure environment variable management |
| tsx | TypeScript execution | Fast, modern TS execution without build steps |
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Client โโโโโโ A2A โโโโโโโโโโถโ Server WeatherAgentExecutor โ
โ (client.ts)โ Protocol โ (Express + A2A SDK) โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โ Weather Agent โ
โ (@openai/agents -- JS) โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโผโโโโโโโ โโโโโโโโโโโโผโโโโโโโโโ
โ Weather Tool โ โ Qedeshator Tool โ
โ(WeatherAPI) โ โ (Azure OpenAI) โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ
- Node.js 18+
- Azure OpenAI API access
- WeatherAPI.com API key (free tier works!)
npm installCreate a .env file with your credentials:
AZURE_OPENAI_API_KEY=your_key_here
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_VERSION=2024-08-01-preview
AZURE_OPENAI_DEPLOYMENT=gpt-4
WEATHER_API_KEY=your_weatherapi_key_herenpm startFor development with hot-reload:
npm run devThe server will start on http://localhost:4000
npx tsx client.ts "What's the weather in Baku?"Expected output (with personality!):
Agent response: Bakida hava indi 16.2ยฐC-dษdi, gรผnษล dษ รงฤฑxฤฑbdฤฑ, can-cigษr. Belษ havada ลษhษrdษ fฤฑrlanmaq lazฤฑmdรผ, รถzรผnรผ gรถstษrmษk gษrษkdi. "Gรผnษล รงฤฑxanda, qษdeลlษr ลษhษrdษdi."
The executor uses an event bus pattern for non-blocking message handling:
const responseMessage: Message = {
kind: 'message',
messageId: uuidv4(),
role: 'agent',
parts,
contextId: requestContext.contextId,
};
eventBus.publish(responseMessage);
eventBus.finished();The agent automatically chains tools based on context:
const weatherAgent = new Agent({
instructions: `If the question is about weather, use the weather tool.
Before sending output, send it to qedeshator tool and output whatever text it gives back.`,
tools: [weatherTool, qedeshatorTool],
});The server exposes its capabilities via standard A2A agent card:
const weatherAgentCard: AgentCard = {
name: 'Weather Agent',
description: 'An Azerbaijani qษdeล who tells you the weather with style',
protocolVersion: '0.3.0',
skills: [{
id: 'weatherTool',
name: 'Weather Tool',
description: 'Tells you the weather in a city',
tags: ['weather', 'city', 'temperature']
}],
};- Streaming responses for real-time interaction
- Push notifications for weather alerts
- State transition history tracking
- Multi-modal inputs (images, audio)
- Agent-to-agent direct communication
- Redis-backed task store for horizontal scaling
- WebSocket support for bidirectional streaming
This project demonstrates advanced AI agent patterns. Feel free to fork and experiment!
MIT
Builing the future with โ and curiosity