Skip to main content
AG-Kit provides support for the A2A (Agent-to-Agent) protocol, enabling multi-agent systems and agent collaboration. Currently supported through AG-UI integration, with planned native server implementation.

AG-Kit A2A Support

Current Implementation

AG-Kit currently supports A2A communication through AG-UI protocol integration:
  • AG-UI Integration: A2A agents can communicate through AG-UI protocol
  • Agent Discovery: Find and connect to other A2A-compatible agents
  • Message Routing: Efficient message delivery between agents
  • Collaboration Patterns: Support for delegation and coordination

Planned Implementation

Future AG-Kit releases will include native A2A server implementation:
  • Native A2A Server: Direct A2A protocol endpoints
  • Service Integration: Enable other systems to use AG-Kit agents via A2A
  • Advanced Coordination: Enhanced multi-agent coordination patterns
  • Performance Optimization: Optimized for high-throughput agent communication

Current A2A Support

AG-UI Based A2A Integration

Use AG-UI protocol for agent-to-agent communication:
import { Agent } from '@ag-kit/agents';
import { OpenAIProvider } from '@ag-kit/providers/openai';

const provider = new OpenAIProvider({
  apiKey: process.env.OPENAI_API_KEY,
  defaultModel: 'gpt-4'
});

const localAgent = new Agent({
  name: 'coordinator-agent',
  model: provider,
  instructions: 'You coordinate with other agents.'
});

// A2A communication through HTTP requests
async function delegateTask(task: any) {
  const response = await fetch('http://other-agent:3000/send-message', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      messages: [{
        role: 'user',
        content: `Agent task: ${JSON.stringify(task)}`
      }]
    })
  });
  return response.json();
}

// Note: Agent event handling would be implemented in the agent's run method

Agent Discovery

Discover and connect to other A2A agents:
// Agent discovery through registry service
async function discoverAgents(capabilities: string[]) {
  const response = await fetch('http://agent-registry:8080/agents', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      capabilities,
      location: 'same_network'
    })
  });
  return response.json();
}

const agents = await discoverAgents(['data_processing', 'analysis']);

// Connect to discovered agents
for (const agentInfo of agents) {
  console.log(`Found agent: ${agentInfo.name} at ${agentInfo.endpoint}`);
  // Use HTTP requests to communicate with discovered agents
}

Collaboration Patterns

  • Task Delegation: Delegate tasks to specialized agents
  • Multi-Agent Coordination: Coordinate multiple agents for complex workflows
  • Agent Debate: Enable agents to debate and reach consensus
  • Message Routing: Efficient message delivery between agents

Planned Native A2A Implementation

Native A2A Server

Future implementation will include native A2A server endpoints:
import { run } from '@ag-kit/server';
import { Agent } from '@ag-kit/agents';
import { OpenAIProvider } from '@ag-kit/providers/openai';

const provider = new OpenAIProvider({
  apiKey: process.env.OPENAI_API_KEY,
  defaultModel: 'gpt-4'
});

const myAgent = new Agent({
  name: 'a2a-agent',
  model: provider,
  instructions: 'You are an A2A compatible agent.'
});

// Future A2A server implementation
run({
  createAgent: () => ({ agent: myAgent }),
  port: 3001
});

// A2A endpoints would be added in future versions
// a2aServer.registerA2AEndpoint('/agents/discover', {
//   method: 'GET',
//   handler: async (req) => await discovery.findAgents(req.query)
// });

Current Limitations

  • AG-UI Dependency: Current implementation requires AG-UI protocol
  • Limited Coordination: Basic coordination patterns only
  • Performance: Not optimized for high-throughput scenarios
  • Discovery: Limited agent discovery mechanisms

Roadmap

Phase 1: Enhanced AG-UI Integration (Current)

  • Improved A2A support through AG-UI
  • Better agent discovery
  • Enhanced message routing

Phase 2: Native A2A Server (Planned)

  • Native A2A protocol implementation
  • Direct A2A endpoints
  • Service integration capabilities

Phase 3: Advanced Features (Future)

  • Advanced coordination patterns
  • Performance optimization
  • Enterprise features