Skip to main content
Enable seamless agent-to-agent communication with the A2A (Agent-to-Agent) protocol.

Quick Start

1

Create an A2A Server

import { A2A, A2AAgentCard } from 'praisonai';

const a2a = new A2A({
  name: "Research Assistant",
  description: "Helps with research tasks",
  url: "http://localhost:8000",
  version: "1.0.0",
  skills: [
    {
      id: "search",
      name: "Web Search",
      description: "Search the web for information"
    }
  ]
});

// Get agent card
const card = a2a.getAgentCard();
console.log(card);
2

Send Messages

import { A2AMessage, A2ARole } from 'praisonai';

const message: A2AMessage = {
  role: A2ARole.USER,
  parts: [
    { type: 'text', text: 'Search for AI news' }
  ]
};

A2A Types

Task States

import { A2ATaskState } from 'praisonai';

A2ATaskState.PENDING    // Task is waiting
A2ATaskState.RUNNING    // Task is executing
A2ATaskState.COMPLETED  // Task finished successfully
A2ATaskState.FAILED     // Task failed
A2ATaskState.CANCELED   // Task was canceled

Roles

import { A2ARole } from 'praisonai';

A2ARole.USER   // User message
A2ARole.AGENT  // Agent message

Message Parts

Text Part

import { A2ATextPart } from 'praisonai';

const textPart: A2ATextPart = {
  type: 'text',
  text: 'Hello, agent!'
};

File Part

import { A2AFilePart } from 'praisonai';

const filePart: A2AFilePart = {
  type: 'file',
  file: {
    name: 'document.pdf',
    mimeType: 'application/pdf',
    uri: 'https://example.com/doc.pdf'
  }
};

Data Part

import { A2ADataPart } from 'praisonai';

const dataPart: A2ADataPart = {
  type: 'data',
  data: {
    results: [1, 2, 3],
    metadata: { source: 'api' }
  }
};

A2A Message

interface A2AMessage {
  role: A2ARole;              // USER or AGENT
  parts: A2APart[];           // Message parts
  metadata?: Record<string, any>;
}

A2A Task

interface A2ATask {
  id: string;                 // Task ID
  sessionId?: string;         // Session ID
  status: A2ATaskStatus;      // Current status
  artifacts?: A2AArtifact[];  // Generated artifacts
  history?: A2AMessage[];     // Message history
  metadata?: Record<string, any>;
}

interface A2ATaskStatus {
  state: A2ATaskState;        // Task state
  message?: A2AMessage;       // Status message
  timestamp?: string;         // When updated
}

Agent Card

Describe your agent’s capabilities:
interface A2AAgentCard {
  name: string;               // Agent name
  description?: string;       // What the agent does
  url: string;                // Agent endpoint
  version: string;            // Version
  provider?: {
    organization: string;
    url?: string;
  };
  capabilities?: {
    streaming?: boolean;
    pushNotifications?: boolean;
    stateTransitionHistory?: boolean;
  };
  skills?: A2AAgentSkill[];   // Agent skills
}

Agent Skills

interface A2AAgentSkill {
  id: string;                 // Skill ID
  name: string;               // Skill name
  description?: string;       // What it does
  tags?: string[];            // Tags for discovery
  examples?: string[];        // Example prompts
  inputModes?: string[];      // Accepted input types
  outputModes?: string[];     // Output types
}

Send Message Request

interface A2ASendMessageRequest {
  id: string;
  jsonrpc: '2.0';
  method: 'message/send';
  params: {
    id: string;
    sessionId?: string;
    message: A2AMessage;
    acceptedOutputModes?: string[];
    pushNotificationConfig?: {
      url: string;
      token?: string;
    };
    metadata?: Record<string, any>;
  };
}

Common Patterns

import { A2A, A2AAgentSkill } from 'praisonai';

const skills: A2AAgentSkill[] = [
  {
    id: "web-search",
    name: "Web Search",
    description: "Search the web for information",
    tags: ["search", "research"],
    examples: ["Find latest AI news", "Search for Python tutorials"]
  },
  {
    id: "summarize",
    name: "Summarize",
    description: "Summarize long documents",
    tags: ["text", "summary"]
  }
];

const a2a = new A2A({
  name: "Research Agent",
  description: "AI-powered research assistant",
  url: "http://localhost:8000",
  version: "1.0.0",
  skills
});

API Reference

A2A

A2A protocol class reference

Best Practices

Each skill should have a clear description and examples for discovery.
Use text for simple messages, file for documents, data for structured data.
Always update task state to keep clients informed of progress.

Agent Team

Multi-agent orchestration

AGUI

Agent GUI protocol