惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
腾讯CDC
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
美团技术团队
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
博客园_首页
Recent Announcements
Recent Announcements
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
博客园 - Franky
Jina AI
Jina AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Agent Series (11): A2A Protocol — How Agents Collaborate ...
WonderLab · 2026-06-03 · via DEV Community

MCP Solved Agent ↔ Tool. Who Solves Agent ↔ Agent?

The previous article covered MCP: an Agent connects to tool services via a standard protocol. Tools are passive — they wait to be called, execute, return a result.

But some scenarios require delegating to another Agent with autonomous decision-making, not just a tool:

  • You have a Research Agent, expert at collecting and analyzing technical material
  • You have a Writing Agent, expert at turning analysis into readable documents
  • You have a Code Review Agent, expert at finding security issues

When these three Agents need to collaborate, how do they communicate? Who knows who exists? How do they hand off work?

This is the problem A2A (Agent-to-Agent) Protocol solves.

MCP:  Agent  ←→  Tools/Data (vertical integration, Agent invokes tools)
A2A:  Agent  ←→  Agent      (horizontal collaboration, Agent delegates to Agent)

Enter fullscreen mode Exit fullscreen mode


A2A's Three Core Concepts

AgentCard: An Agent's Business Card

Each Agent publishes an AgentCard describing its capabilities:

from a2a.types import AgentCard, AgentSkill

research_card = AgentCard()
research_card.name = "research-agent"
research_card.description = "Gathers factual background on technical topics"

skill = AgentSkill()
skill.id = "research"
skill.name = "Research"
skill.description = "Collect key facts on a topic"
skill.tags.extend(["research", "facts"])
research_card.skills.append(skill)

Enter fullscreen mode Exit fullscreen mode

Key AgentCard fields: name, description, skills (each skill has tags for discovery).

Think of it as the Agent equivalent of OpenAPI Spec — a machine-readable capability declaration that humans can also read.

Task: The Unit of Work

Agents don't pass function calls to each other — they pass Task objects:

from a2a.types import Task, TaskState, TaskStatus, Message, Part, Role

task = Task()
task.id = str(uuid.uuid4())
task.status.state = TaskState.TASK_STATE_SUBMITTED

# Input: a User-role Message
msg = Message()
msg.role = Role.ROLE_USER
part = Part(); part.text = "Should I use Python or Go?"
msg.parts.append(part)
task.history.append(msg)

Enter fullscreen mode Exit fullscreen mode

Task has a lifecycle: SUBMITTED → WORKING → COMPLETED / FAILED. On completion, the Agent appends the result as a ROLE_AGENT Message.

Registry: The Agent Yellow Pages

AgentRegistry stores all registered AgentCards and supports discovery by tag:

class AgentRegistry:
    def register(self, card: AgentCard, handler: Callable[[Task], Task]) -> None:
        self._agents[card.name] = AgentEntry(card=card, handler=handler)

    def discover(self, tag: str) -> list[AgentCard]:
        """Return all agents whose skills include the given tag."""
        ...

    def delegate(self, agent_name: str, input_text: str) -> Task:
        """Create a Task and execute it via the registered handler."""
        ...

Enter fullscreen mode Exit fullscreen mode


Demo 1: Direct Calls — Simple but Tightly Coupled

Without a protocol, the orchestrator calls three Python functions directly:

def direct_orchestrator(question: str) -> str:
    research = research_agent_fn(question)    # hard dependency
    analysis = analysis_agent_fn(research)   # hard dependency
    answer   = writing_agent_fn(analysis)    # hard dependency
    return answer

Enter fullscreen mode Exit fullscreen mode

Real execution output:

→ calling research_agent (direct)
→ calling analysis_agent (direct)
→ calling writing_agent (direct)

Answer: Choose Python if you need rapid development with broad libraries.
        Select Go if performance and concurrency are critical...

Enter fullscreen mode Exit fullscreen mode

Works perfectly. The problem is structural: the orchestrator has three hardcoded function references. Replace any one Agent, and you must edit the orchestrator. If the orchestrator lives in a different service, that means a cross-service code change.


Demo 2: A2A AgentCard Registry

Register three Agents, each with distinct skill tags:

[registry] registered: research-agent
[registry] registered: analysis-agent
[registry] registered: writing-agent

Enter fullscreen mode Exit fullscreen mode

Discovery test:

researchers = registry.discover("research")
# → Found: research-agent — Gathers factual background on technical topics

writers = registry.discover("writing")
# → Found: writing-agent — Composes clear technical prose from analysis output

Enter fullscreen mode Exit fullscreen mode

The orchestrator never writes an agent name — it discovers by tag:

def a2a_orchestrator(question: str) -> str:
    researchers = registry.discover("research")
    t1 = registry.delegate(researchers[0].name, question)

    analysts = registry.discover("analysis")
    t2 = registry.delegate(analysts[0].name, task_output(t1))

    writers = registry.discover("writing")
    t3 = registry.delegate(writers[0].name, task_output(t2))
    return task_output(t3)

Enter fullscreen mode Exit fullscreen mode

Real execution output:

→ delegating to research-agent (discovered via tag)
→ delegating to analysis-agent (discovered via tag)
→ delegating to writing-agent (discovered via tag)

Answer: Choose Python for rapid development; Go for high-throughput performance...

Enter fullscreen mode Exit fullscreen mode

The critical difference: the orchestrator code contains no agent names. Register a writing-agent-v2 with the same writing tag, and the orchestrator discovers and uses it immediately — zero code changes.


Demo 3: LLM-Driven Agent Routing

A2A's most powerful use case: the LLM reads the AgentCard catalog and decides which Agents to call and in what order.

Show the LLM the agent catalog:

Available agents:
  research-agent: Gathers factual background [skills: Research(research, facts)]
  analysis-agent: Analyzes research notes    [skills: Analysis(analysis, tradeoffs)]
  writing-agent:  Composes technical prose   [skills: Writing(writing, prose)]

Enter fullscreen mode Exit fullscreen mode

LLM outputs an execution plan:

["research-agent", "analysis-agent", "writing-agent"]

Enter fullscreen mode Exit fullscreen mode

Execute the plan:

Executing 3 agents:
  → delegating to research-agent
  → delegating to analysis-agent
  → delegating to writing-agent

Final answer: Choose Python for rapid development; Go for high-throughput...

Enter fullscreen mode Exit fullscreen mode

This is A2A's end state: no pre-configured orchestrator pipeline. The LLM reads the task requirements and the AgentCard descriptions, then plans the collaboration chain at runtime.


MCP vs A2A vs ANP: Protocol Selection Matrix

Dimension         MCP                          A2A
──────────────────────────────────────────────────────────────────────
Problem solved    Agent ↔ Tool/Data            Agent ↔ Agent
Discovery         list_tools() (tool catalog)  discover() (Agent registry)
Unit of work      Tool call (sync)             Task (async-ready)
Coupling          Agent invokes tool directly  Orchestrator delegates task
Other end         Passive tool service         Autonomous Agent with logic
Cross-service     Tool is an independent proc  Agent is an independent service
Who decides       Agent (tool use)             Orchestrator (delegation)

Enter fullscreen mode Exit fullscreen mode

Complete four-way selection guide:

Scenario                                  Recommended
──────────────────────────────────────────────────────────────────────
Same codebase, call target known          Direct function call
Agent needs external tools                MCP (tools as service)
Agent delegates to specialist Agents      A2A (agents as service)
Cross-org large-scale Agent network       ANP (decentralized discovery)

Enter fullscreen mode Exit fullscreen mode


Design Checklist

AgentCard Design

  • [ ] description: one sentence about what the Agent is good at — the LLM reads it for routing decisions
  • [ ] skill.tags: use semantically clear tags (research, analysis, writing), not version numbers or internal IDs
  • [ ] AgentCard should be machine-readable and human-readable (think OpenAPI style)

Task Design

  • [ ] Task.id: use UUID for tracking and idempotent retry
  • [ ] Use history (Message chain) for context passing — don't concatenate everything into part.text
  • [ ] Distinguish ROLE_USER (input) from ROLE_AGENT (output) messages

Registry and Discovery

  • [ ] One tag can map to multiple Agents (load balancing, A/B testing)
  • [ ] Support tag-based filter AND exact-name lookup
  • [ ] Production: use a persistent registry (database or service registry), not an in-memory dict

LLM-Driven Routing

  • [ ] Keep the agent catalog concise: name + description + skill tags. Don't dump the full AgentCard JSON to the LLM
  • [ ] Validate the LLM's output: handle unknown agent names with a fallback path
  • [ ] Log the LLM-generated execution plan for post-hoc analysis and debugging

Summary

Five core takeaways:

  1. A2A and MCP are complementary, not competing: MCP is Agent-invokes-tool; A2A is Agent-delegates-to-Agent. A single system can use both protocols
  2. AgentCard is the heart of A2A: it transforms an Agent from a hardcoded dependency into a discoverable, composable service unit
  3. Task is a richer unit of work than a function call: it has a lifecycle, is async-ready, and carries structured history
  4. The direct-call vs A2A dividing line: same team, same codebase → direct call; cross-service, need decoupling → A2A
  5. LLM-driven routing is A2A's highest form: Agents plan their own collaboration chain based on task descriptions, with no pre-configured orchestrator pipeline

Up next: Agent Evaluation Framework — how to systematically test Agents, which metrics matter, and how to use DeepEval.


References


Find more useful knowledge and interesting products on my Homepage