الأكاديمية ← قنوات المراسلةتوثيق رسمي · إرشاد عربي

التواصل بين الوكلاء A2A

A2A (Agent-to-Agent)

متوسط5 دقائق قراءةالدرس 295 أسئلة✓ 2026-08-18
قبل أن تقرأ

ما هذه الصفحة، وماذا تحتوي.

بوابة المراسلة: الوصلة التي تجعلك تكلّم Hermes من تطبيق تستعمله أصلًا، مثل Telegram أو WhatsApp، بدل الطرفية. الوكيل الذي تصله من هاتفك تستعمله فعلًا. الذي يحتاج فتح الحاسوب تنساه بعد أسبوع. ستستعمل هنا hermes tools enable a2a وhermes gateway setup، والقراءة نحو 5 دقائق. انتبه: افتح القناة لنفسك فقط في البداية عبر قائمة سماح. القناة المفتوحة تعني أن أي شخص يراسل وكيلك.

8أقسام
5أمثلة برمجية
2جداول
2أوامر
845كلمة من المصدر
ماذا ستستطيع بعدها

نتائج مأخوذة من هذه الصفحة، لا من قالب.

  • تعرف ما بوابة المراسلة ولماذا قد تحتاجه.
  • تنفّذ hermes tools enable a2a وhermes gateway setup وتفهم ما يحدث بعدها.
  • تقرأ الجدول وتأخذ منه السطر الذي يخصّك فقط.
  • تضبط A2A_HOST في المكان الصحيح.
ما ستقابله من أسماء

كما تظهر تمامًا داخل Hermes.

الأوامر
  • hermes tools enable a2a
  • hermes gateway setup
متغيرات البيئة
  • A2A_HOST
  • A2A_PUBLIC_URL
  • ROLE_USER
  • A2A_PEER_TOKENS
  • A2A_BEARER_TOKEN
  • A2A_REPLY_TIMEOUT
خريطة الصفحة

انتقل مباشرة إلى ما تحتاجه.

  1. 01When to use A2A
  2. 02Enable
  3. 03Outbound: calling other agents
  4. 04Inbound: being callable
  5. 05Security model
  6. 06Configuration reference
  7. 07Quick test
  8. 08Troubleshooting
الصفحة الرسمية كاملة

بلا اختصار أو حذف.

النص أدناه منقول من المصدر الرسمي بالإنجليزية حتى تبقى الأوامر والأسماء دقيقة كما هي. قبل كل قسم شرح عربي يوضّح ما بداخله.

A2A ↗ is the open Agent2Agent protocol (v1.0, stewarded by the Linux Foundation) for communication between independent AI agents. The Hermes A2A plugin works in both directions: your agent can call other A2A agents as tools, and other agents can send tasks to your Hermes over HTTP.

It interoperates with any A2A-compliant peer — another Hermes, LangChain, CrewAI, Google ADK agents, or anything built on the official a2a-sdk.

When to use A2A

شرح للفكرة نفسها. اقرأه ببطء، فبقية الأقسام تبني عليه. تذكير: الوصلة التي تجعلك تكلّم Hermes من تطبيق تستعمله أصلًا، مثل Telegram أو WhatsApp، بدل الطرفية.

  • Hermes ↔ Hermes across machines — let your desktop agent hand tasks to a Hermes on a server, or vice versa, each with its own memory, tools, and credentials.
  • Delegating to specialist agents — a peer that advertises web_search/research/coding skills on its Agent Card can be discovered and called mid-conversation.
  • Being a callable service — expose your Hermes so other frameworks' agents can send it tasks.

When you want multiple agents on the same machine, prefer delegation (in-process subagents) or the kanban board (durable multi-profile work queue) — A2A is for crossing process/machine/framework boundaries.

Enable

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. الأوامر هنا: hermes gateway setup.

Shellسطر واحد
hermes gateway setup      # pick A2A

Or in ~/.hermes/config.yaml:

YAML6 أسطر
gateway:
  platforms:
    a2a:
      enabled: true
      extra:
        port: 9900

The outbound client tools ship as the a2a toolset, off by default — enable it per platform:

Shell3 أسطر
hermes tools enable a2a --platform cli        # CLI/TUI sessions
hermes tools enable a2a --platform telegram   # or any messaging platform
hermes tools enable a2a --platform a2a        # let inbound A2A tasks call peers (agent chaining)

The tools are available in every process type — CLI, TUI, gateway, and cron — without the inbound platform needing to be enabled.

Outbound: calling other agents

جدول مرجعي. لا تقرأه كله، ابحث عن السطر الذي يخصّك فقط.

With the a2a toolset enabled, the agent gets:

ToolWhat it does
a2a_discover(url)Fetch and summarize a peer's Agent Card
a2a_call(agent, message, context_id?)Send a task, get the reply; multi-turn via context_id
a2a_list()Configured peers, saved conversations, metrics
a2a_history(context_id)Recall a persisted A2A conversation
a2a_orchestrate(capability, message, mode?)Fan a task out to every peer advertising a capability (all / first / best)

Configure known peers in config.yaml:

YAML6 أسطر
a2a_agents:
  researcher:
    url: "http://research-box.local:9900"
    auth: { type: bearer, token: "..." }
    timeout: 120
    capabilities: [web_search, research]

Then just ask: "Ask the researcher agent to summarize today's arXiv postings." Direct URLs work too — a2a_call accepts any A2A endpoint.

Inbound: being callable

شرح للفكرة نفسها. اقرأه ببطء، فبقية الأقسام تبني عليه.

With the platform enabled, Hermes serves:

  • Agent Card at GET /.well-known/agent-card.json (canonical v1.0 path; the legacy agent.json also answers) — advertises your agent's name, skills (derived from enabled toolsets), and auth requirements.
  • JSON-RPC 2.0 at POST / — canonical v1.0 methods (SendMessage, SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, push-notification config CRUD) plus the pre-1.0 path-style aliases (message/send, …).
  • SSE streaming for SendStreamingMessage, with spec-correct JSON-RPC-enveloped frames.
  • Push notifications (webhooks) for long-running tasks, HMAC-SHA256 signed.

Inbound tasks are injected into a live gateway session — the same agent, memory, and tools that serve your other channels — and the final reply is returned to the caller as the task result. Conversations are keyed by the A2A contextId, so a peer can hold a multi-turn exchange.

Interoperability is verified against the official Python a2a-sdk (card resolution, SendMessage, streaming).

Security model

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. تضبط A2A_HOST خارج المحادثة، في بيئة التشغيل.

Secure by default; every widening step is explicit:

  • No token ⇒ localhost only. The server binds 127.0.0.1. Remote exposure requires a bearer token and an explicit A2A_HOST.
  • Per-peer tokens — A2A_PEER_TOKENS="alice:tok1,bob:tok2" gives each peer its own credential; the authenticated name drives rate limiting, trust, and audit.
  • Prompt-injection filtering — inbound text is filtered and framed as untrusted peer input. Remote peers cannot invoke operator slash commands.
  • Outbound redaction — credential-shaped strings (API keys, JWTs, tokens) are scrubbed from replies.
  • Audit log — every exchange appends to ~/.hermes/a2a_audit.jsonl.
  • Anti-loop — per-context turn caps stop two agents ping-ponging forever.

Configuration reference

جدول مرجعي. لا تقرأه كله، ابحث عن السطر الذي يخصّك فقط.

Env varDefaultMeaning
A2A_PEER_TOKENS_(unset)_Per-peer credentials name:token,… (preferred)
A2A_BEARER_TOKEN_(unset)_Shared token; identity falls back to caller IP
A2A_HOST127.0.0.1Bind host — only widens when a token is set
A2A_PORT9900Inbound port
A2A_AGENT_NAMEhostname-derivedName on the Agent Card
A2A_PUBLIC_URL_(unset)_Routable URL advertised on the card (reverse proxies / k8s)
A2A_TRUSTED_PEERS_(unset)_Allow-list of authenticated identities
A2A_ALLOW_ALL_USERSfalseAllow any authenticated peer (dev only)
A2A_RATE_LIMIT60Requests/minute per identity
A2A_MAX_PINGPONG_TURNS5Anti-loop turn cap per context (max 20)
A2A_REPLY_TIMEOUT300Seconds to wait for the agent's reply
A2A_PUSH_SECRETbearer tokenHMAC secret for push-notification signing
A2A_ADVERTISED_TOOLSETSall registeredRestrict which skills appear on the Agent Card

Behind a reverse proxy or Kubernetes Service, set A2A_PUBLIC_URL (or rely on X-Forwarded-Host/X-Forwarded-Proto) so the Agent Card advertises a URL peers can actually call back.

Quick test

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. تضبط ROLE_USER خارج المحادثة، في بيئة التشغيل.

Shell9 أسطر
# From another machine / agent:
curl http://your-host:9900/.well-known/agent-card.json

curl -X POST http://your-host:9900/ \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <token>' \
  -d '{"jsonrpc":"2.0","id":1,"method":"SendMessage",
       "params":{"message":{"messageId":"m1","role":"ROLE_USER",
                 "parts":[{"text":"What tools do you have?"}]}}}'

Troubleshooting

قسم لحل المشكلات. ابحث فيه عن العطل الذي يشبه حالتك بدل قراءته كاملًا.

  • Peers can't reach the card URL — the card was advertising your bind address; set A2A_PUBLIC_URL to the externally routable URL.
  • 401 Unauthorized — token mismatch; check A2A_PEER_TOKENS/A2A_BEARER_TOKEN on the server and the peer's auth: block.
  • Server won't bind non-localhost — by design: set a bearer token first, then A2A_HOST=0.0.0.0.
  • Replies time out on long tasks — raise A2A_REPLY_TIMEOUT, or have the caller register a push-notification config and poll GetTask.
اختبار الفهم

5 أسئلة إجاباتها كلها في هذه الصفحة.

كل خيار اسم حقيقي من توثيق Hermes. حتى الخيارات الخاطئة حقيقية، لكنها من صفحات أخرى.

1. بحسب هذا الدرس، أي أمر يقوم بـ«pick A2A»؟
2. في جدول هذا الدرس، ما «What it does» المقابل لـ«a2ahistory(contextid)»؟
3. أي متغير بيئة من التالي يظهر فعليًا في هذا الدرس؟
4. أي عنوان من التالي لا يظهر في هذا الدرس؟
5. أي مفتاح إعداد يظهر في أمثلة هذا الدرس؟