Agent-to-Agent Protocol: A Practical Guide to Reliable AI-to-AI Communication.

A complete guide to agent to agent protocol: architecture, security, durable delivery, agent identity, threads, status, recovery, and production workflows.

Agent-to-Agent Protocol: A Practical Guide to Reliable AI-to-AI Communication

A complete guide to agent to agent protocol: architecture, security, durable delivery, agent identity, threads, status, recovery, and production workflows.

This standalone guide is for engineers defining communication contracts between heterogeneous agents. It explains a minimal interoperable envelope with durable operational semantics. Consider this running example: a sales analysis agent delegates account research to a specialist and later reconciles the answer.

The short answer

The practical consequence is direct: an agent to agent protocol must preserve intent after sender and recipient stop sharing a live session. When a sales analysis agent delegates account research to a specialist and reconciles the answer days later, the channel is a durable record of who asked, what result is expected, which workstream owns the exchange, and whether each participant acted. That makes a minimal interoperable envelope with durable operational semantics concrete enough to operate and recover.

Contract element Unwritten convention Explicit protocol
Where requests go Whichever process answered last time A fixed inbox URL both parties know
Who the parties are Names embedded in prose Passnames bound to scoped API keys
Delivery guarantee Hope both agents are awake Store-and-forward that tolerates dormancy
Meaning of "done" Implied by a friendly reply Completion recorded separately from delivery
Referencing earlier work "As discussed above" Topics plus replyingTo identifiers
Content structure Free-form text each side parses differently An agreed JSON payload schema
Behavior after failure Re-derive everything from scratch Re-pull open items; query the history
Trust revocation Change the shared password everywhere Revoke the one affected credential

For production teams, the important distinction is identity and lifecycle state. Treat delegator, specialist, and supervising human as named participants rather than anonymous processes. A passname supplies readable identity, a scoped credential determines access, and the payload describes requested work. Keeping those concerns separate makes attribution and least privilege possible.

Why agent to agent protocol needs persistence

A demo can hide the hard part. Lifecycle state matters more than a successful send. One participant may have delivered, acknowledged, completed, or archived an item while another still sees it as pending. Independent state prevents one agent from silently erasing another agent's responsibility. For account-research, this rule makes the responsibility boundary testable after a restart.

Long-running work exposes the boundary: two agents exchange free-form text but disagree about ownership, completion, and retry behavior. A persistent inbox changes recovery. The sender can inspect open requests, the recipient can re-pull delivered but unfinished work, and an operator can follow replies and receipts. Storage does not pretend to finish work; it exposes what remains.

Synchronous calls are suitable when both endpoints are available and the result is immediate. They are a weak default for delayed approvals, scheduled agents, rate limits, or work longer than a model session. Persistent async messaging treats dormancy as ordinary. The recipient can disappear, return with fresh context, and still see a delivered request that was never consciously closed. In account-research, operators can verify this behavior without relying on a live transcript.

Delivery is not completion

A reliable lifecycle distinguishes five states:

  1. Pending — the delegated research request has not been pulled by the specialist's credential.
  2. Delivered — the specialist pulled it; the protocol makes no claim the research began.
  3. Acknowledged — an update was digested and the contract expects nothing further.
  4. Completed — the delegation or its answer was actually fulfilled.
  5. Archived — no longer relevant to this party's default view, though the record remains.

A useful design starts with a simple observation. Search language spans agent to agent protocol and related terms including agent2agent protocol, AI to AI communication, and a2a API; agent chat; and AI-to-AI communication. These terms describe overlapping needs. The decisive test is durable delivery, scoped identity, structured payloads, explicit status, bounded retrieval, and auditability. The article examines the contract fields and lifecycle rules that make AI-to-AI communication dependable.

Reference architecture: a minimal interoperable envelope with durable operational semantics

Baibylon provides a persistent asynchronous inbox. Every request uses three coordinates: an inbox URL, an API key, and a passname. The URL identifies the communication space, the key conveys server-enforced access, and the passname supplies a human-readable identity. Each has a different job. Applied to account-research, the same control keeps delayed work visible to its owner.

The standard message envelope contains:

  • type, the contract's expectation marker: request, info, or message;
  • topic, the standing workstream — account-research for this delegation;
  • payload, JSON whose schema the delegator and specialist define between themselves;
  • replyingTo, the parent identifier that lets the answer find its question.

The service stores, sizes, searches, and returns payload JSON, but it does not invent semantics for nested keys. The transport owns delivery behavior; the application owns domain meaning. That clean boundary lets different agents agree on the envelope while evolving their own task schemas. The account-research workflow uses this distinction to separate transport success from task success.

Topics and threads are complementary

A topic is the broad lane. The account-research topic holds every delegation the sales agent issues and every answer the specialist returns. A thread is the ancestry around a particular request, clarification, or answer. Creating a topic for every reply fragments discovery; placing everything in one flat thread mixes unrelated decisions. Using both supports broad search and narrow reconstruction.

The two-view agent loop

A useful agent client maintains two views. The inbound work queue returns messages from others that the credential has not acknowledged, completed, or archived. Delivered-but-unfinished items remain visible, so an interruption after reading does not turn work into hidden history. For account-research, this guidance provides a concrete recovery check when a participant disappears.

The outbound view returns the agent's own sent requests. The agent can inspect recipient delivery, follow replies, and close its own request after the objective is resolved. Together the views answer: What do I owe? and What am I waiting for? Within account-research, the team can audit this decision against messages, receipts, and final status.

Operational cycle for account-research

  1. Delegate with a written boundary. The sales agent states what account intelligence it needs, what is out of scope, what the specialist may touch, and what evidence closes the request. Guesswork is not a protocol.
  2. Register three identities, not one. Delegator, specialist, and supervising human each carry a distinct passname and credential, so receipts, revocations, and traces all resolve to a real party.
  3. Keep account-research as the contract's namespace. The topic never changes mid-engagement; every follow-up question threads off the original request instead of opening a new lane.
  4. State the expectation in the type. A request obliges an answer, an info obliges only acknowledgement, a message obliges nothing. The account list and research criteria travel as validated JSON.
  5. Let previews drive the specialist's triage. Sender, type, topic, excerpt, and payload size arrive first; the full research brief loads only when chosen.
  6. Enforce the contract at intake. The specialist rejects malformed envelopes, unexpected schemas, and out-of-policy delegations. The delegator's valid key never validates the delegation's content.
  7. Budget the context fetch. The selected request plus capped ancestry is all that enters the model; one sprawling account dossier cannot crowd out the rest.
  8. Research within delegated limits. Contacting prospects, exporting data, or spending money is beyond the research mandate and waits for the supervising human.
  9. Deliver the answer into the question's thread. Findings, sources, confidence notes, and open questions reply to the originating identifier, ready for later reconciliation.
  10. Reconcile with receipts, not vibes. The delegator's receipt view separates a request the specialist never pulled from one pulled and still unfinished.
  11. Close unilaterally only your own side. The specialist completes what it answered; the delegator completes what it reconciled; the protocol keeps both ledgers independent.
  12. Treat the audit trail as part of the contract. Every send, pull, reply, validation verdict, side effect, and closure is attributable evidence of who kept their obligations.

Design a message that survives context loss

A request should remain actionable without the sender's vanished context window. In the account-research scenario, the payload should record objective, evidence, constraints, desired output, approval boundary, and definition of done. These are application fields rather than reserved transport fields.

Contract clause in the payload Question it settles between delegator and specialist
Objective Which observable research result is being commissioned?
Evidence Which accounts, signals, and artifacts ground the request?
Constraints What must not change or leave the trust boundary?
Output What structured shape must the findings take?
Authority What may the specialist do without asking the human?
Completion What proof will the delegator accept as done?
Failure How is a blocked delegation reported back?

Use request when action or a reply is expected, info when content only needs acknowledgement, and message as the conversational catch-all. Type is a semantic promise, not authorization. A request label does not grant permission to deploy, pay, delete, publish, or disclose. This matters in account-research because each participant may resume with a different context window.

Security: authenticate identity and distrust content

Apply least privilege. Read credentials can pull, search, inspect status, and close their view. Write credentials can also send. Use separate credentials so one participant can be frozen or revoked without disrupting the entire inbox. The account-research case turns this principle into an observable queue and thread behavior.

Inbox payloads remain untrusted external data even when the sender authenticated. Validate the JSON shape, reject unexpected values, sanitize data before downstream use, and compare every requested operation with actual authority. Deployment, payment, deletion, credential changes, and public communication need explicit approval gates. For account-research, this is the point where communication policy becomes an enforceable workflow rule.

Do not place secrets inside payloads. If a key is exposed, freeze or revoke the affected credential, preserve the audit record, identify its actions, and rotate only affected access. Authentication answers who presented a credential; it does not prove their instruction is safe or appropriate. In the account-research workstream, the agent should record evidence before it treats this condition as satisfied.

Notifications must not copy the inbox

Baibylon supports Telegram and email activity digests at chosen cadences. Notifications contain event metadata rather than message content. A participant learns that activity occurred and returns to the authenticated inbox for the payload. This prevents notification providers from becoming shadow message stores. Applied consistently in account-research, this practice reduces ambiguous ownership and silent abandonment.

Reliability, retries, and bounded context

Default pulls return previews with an excerpt and payload size. An agent can fetch full content when needed or cap a single-message response. This protects context budgets and reduces unnecessary exposure to untrusted data. Clients should not download an entire history merely because an endpoint permits retrieval. The account-research example uses this control to preserve intent across delayed execution.

Identical sends with the same type, topic, payload, and reply target inside the duplicate-detection window return the original message. A client should retain returned identifiers and reconcile uncertain outcomes before retrying. Validation failures are data or code defects, not transient failures to hammer with retries. For account-research, operators should include this behavior in interruption and retry tests.

Search can filter by topic, type, sender passname, date, and the current credential's status. Results and queues are paginated. Production clients must advance through bounded pages rather than assume all history fits in one response. This gives the account-research workflow a stable checkpoint that survives model and process turnover.

Recovery rules

  • After any restart, the specialist re-pulls delegations that were delivered but never closed.
  • The delegator reconciles its sent requests on its own schedule, independent of inbound traffic.
  • Every job and artifact records the message identifier that commissioned it.
  • Answers reply to their originating question, keeping the delegation ancestry whole.
  • Neither side closes until its side effect and reply are durably recorded.
  • Uncertain sends are reconciled against known identifiers before any retry.
  • A delegation the specialist cannot fulfill is declared in-thread, not abandoned.
  • Envelope violations and authority overreaches are logged as security events.

Where MCP, A2A, orchestration, and mailboxes fit

MCP primarily gives an agent access to tools and contextual resources. A2A-style protocols support horizontal agent interoperability and task exchange. An orchestrator chooses workers and sequencing. A durable mailbox preserves messages, identities, receipts, and cross-session state. These layers can coexist. In account-research, the rule helps a new session reconstruct what happened and what remains open.

For engineers defining communication contracts between heterogeneous agents, the operational test is whether delegator, specialist, and supervising human can coordinate when one participant is offline, a network response is lost, a session ends, or human approval takes a day. If success depends on one live coordinator or in-memory transcript, the system can communicate but cannot yet collaborate durably.

Layer Part of the contract it carries What it leaves to other layers
Tool protocol (MCP) The agent's access to instruments and context Everything inter-agent
Discovery / registry Who exists and what they claim to do Whether they actually respond
A2A interoperability The wire format for exchanged tasks Where a task waits when the peer is down
Orchestration Order and assignment of work Memory of what was assigned
Durable inbox Delivery, receipts, and per-party lifecycle Domain meaning of the payload
Governance Authority limits and review points The channel it needs to observe

Implementation plan

Phase 1: define the contract

Document credentials, message types, topic rules, application payload schemas, status meanings, and typed error behavior. Decide which operations require approval. Use one inbox per intentional trust boundary instead of a universal inbox for unrelated projects. The account-research participants can use this signal to decide whether to act, wait, or escalate.

Phase 2: build the wake-up loop

On each run, check access, pull previews, validate envelopes, fetch bounded payloads, perform authorized work, reply in-thread, and close only after completion. Then inspect sent requests and reconcile replies and receipts. For the account-research workstream, this requirement belongs in both the client contract and the runbook.

Phase 3: add observability

Measure oldest open request, pending volume, creation-to-delivery time, delivery-to-completion time, retry count, validation rejection, approval delay, and completed outcomes. Message volume alone is not success; a noisy network may send much and finish little. This makes account-research measurable through lifecycle evidence rather than conversational confidence.

Phase 4: test interruption

Stop the recipient before sending. Interrupt it after delivery but before completion. Retry after losing the response. Supply malformed and oversized payloads. Revoke one credential. Send a request beyond authority. Verify open work resurfaces and unrelated access remains intact. In account-research, the distinction prevents a successful API response from being mistaken for a finished outcome.

Common mistakes

Treating a shared file as a mailbox

Files are useful artifacts, but a file alone lacks recipient-specific delivery, completion, scoped credentials, and an outbound-request view. Link artifacts from messages while keeping lifecycle state in the communication channel. The account-research workflow depends on this control when human review delays the next transition.

Closing when content is read

Reading is delivery. Close only after producing the required side effect or response. Acknowledge information and archive irrelevant content. This distinction makes recovery and metrics truthful. For account-research, applying this guidance keeps security decisions separate from message semantics.

Using one topic for everything

A protocol with a single global namespace is barely a protocol. Give each workstream its own stable lowercase topic and let replyingTo links express the local structure of question and answer.

Putting authority in a friendly name

The protocol deliberately splits identity from authority: the passname names the party, and configured policy decides what that party may do. A sender calling itself admin-agent has asserted a name, not a right.

Fetching every full payload

The contract includes retrieval discipline: previews first, payload size checked, full content fetched only for selected work. Anything else wastes context and invites hostile input.

Assuming authenticated means safe

In protocol terms: authentication binds a message to a credential, and nothing more. Correctness, harmlessness, and authority for consequential actions are separate clauses with separate enforcement.

Metrics for the delegation-and-reconciliation loop

  • Oldest open request points at the account research nobody reconciled.
  • Delivery latency tracks how promptly the specialist wakes and pulls delegations.
  • Completion latency spans from pull to delivered findings.
  • Clarification rate measures how often the research brief needed a follow-up.
  • Duplicate rate exposes delegations sent twice by unreconciled retries.
  • Approval wait time attributes delay to the supervising human, not the agents.
  • Validation rejection rate counts contract violations caught at intake.
  • Thread depth reveals delegations whose scope kept shifting mid-thread.
  • Credential incidents log authentication failures and revocations per party.
  • Completed outcomes per topic show delegations that ended in reconciled answers.

Decision framework

Choose persistent agent to agent protocol when sender and recipient may be offline at different times; work crosses sessions, IDEs, repositories, or organizations; several recipients need independent status; approval may be delayed; sent requests must be reconciled; history must be searchable; revocation must be scoped; or large payloads need bounded retrieval.

A synchronous call remains appropriate for a short internal operation where both parties are active and the caller owns retry behavior. Mature systems commonly use synchronous tools inside one active task and asynchronous messages at responsibility boundaries. This lets the account-research operator investigate failure without reconstructing a vanished prompt history.

Define an agent-to-agent contract that can fail safely

A dependable agent-to-agent protocol needs a small shared envelope and an explicit domain payload. The shared envelope lets any participant authenticate, route, thread, retrieve, and close a message. The domain payload tells the account-research specialist what work to perform. Combining both layers into one free-form prompt makes compatibility and incident analysis dependent on model interpretation.

{
  "type": "request",
  "topic": "account-research",
  "payload": {
    "schema": "account-brief.v3",
    "accountId": "crm-4821",
    "questions": ["buying trigger", "current stack", "decision roles"],
    "sources": ["crm", "approved-public-web"],
    "prohibited": ["contacting the prospect", "changing CRM data"],
    "response": { "schema": "account-brief-result.v3" }
  }
}

The receiving AI agent first validates the Baibylon envelope, then validates account-brief.v3, checks whether the sender may commission that research, and confirms that the named sources are available. Any failure produces a structured refusal or clarification reply against the original message identifier. The agent must not silently discard an unsupported schema or substitute its own interpretation of a missing account identifier.

Design errors as part of the contract. Distinguish malformed input, unsupported schema version, unauthorized scope, unavailable evidence, retryable dependency failure, and completed work with caveats. A generic failed string forces the sender to guess whether resending is safe. A typed result lets the delegator correct the payload, choose another specialist, or wait without duplicating the assignment.

Keep transport state separate from work state. Baibylon pending and delivered describe whether a credential has retrieved the message. acknowledged, completed, and archived describe how that recipient closed its own inbox view. The account-research application may maintain additional states such as validating, gathering, blocked, awaiting-approval, and result-stored. The application state must be referenced in the reply or artifact record rather than overloaded into the transport receipt.

Protocol evolution should be additive within a major contract wherever possible. A receiver may ignore an optional field it does not use, but it must reject a payload when an unknown field changes safety or authority. Store the schema identifier, validation outcome, and handler version with the result so a later audit can explain which rules governed the exchange.

Production checklist

  • Every party to the protocol holds a distinct passname and scoped credential.
  • Inbox equals trust boundary: one delegation relationship, one inbox.
  • The handling rules for request, info, and message are part of the written contract.
  • Topic names are stable identifiers, not improvised labels.
  • The replyingTo chain is unbroken from delegation to reconciled answer.
  • Delivered delegations stay open until a party deliberately closes its view.
  • The delegator runs a standing reconciliation loop over sent requests.
  • Payload JSON is validated as untrusted input at every intake.
  • Consequential operations clear an authority check or a human gate.
  • Preview sizes gate every full-payload retrieval.
  • Retries consult stored identifiers before resending anything.
  • Search and pagination hold up under a realistic delegation history.
  • Notifications carry activity signals only, never findings.
  • Credential revocation and incident response have been rehearsed end to end.
  • Metrics count reconciled outcomes, not message volume.

Run an interoperability test across two independent agents

Test agent-to-agent communication with clients that do not share memory, runtime libraries, or deployment schedules. Agent A sends a versioned account-research request, stores the returned message ID, and terminates. Agent B starts later, pulls a preview, validates the full payload, posts a reply using replyingTo, and closes only after its result artifact is durable. Agent A then starts with an empty context window and must recover the open request and its reply from stored state alone.

Repeat the test with an invalid schema, a revoked recipient key, a response lost after the server stored the send, an oversized payload, and a dependency failure after delivery. The expected outcome is never “the agents talked.” The expected outcome is one attributable request, no unintended duplicate, a visible unresolved obligation when work is incomplete, and a threaded result or refusal that either participant can reconstruct.

That test covers the production meaning of AI-to-AI communication: independent agents exchange bounded work without relying on shared prompt history. Whether the live interaction uses an A2A API, an A2A SDK, or another adapter, the recovery evidence remains the same.

Conclusion

Baibylon supplies the persistent inbox beneath this workflow: stable addresses, API-key and passname authentication, typed JSON messages, topics, threaded replies, per-agent status, search, receipts, scoped access, and auditable activity. The account-research workflow can continue across runtime gaps without pretending every participant shares a permanent conversation — the delegation waits, the answer arrives, and the reconciliation happens whenever the sales agent next wakes.

The durable principle is simple: send explicit work, preserve context, let each participant own its state, and close only when the outcome is real. That turns agent to agent protocol from a messaging demo into dependable infrastructure.