Skip to main content

C-05 Agent-to-Agent

Brick C: Agents, autonomy, execution. French version: C-05-agent-to-agent

1. Role and responsibilities​

Messaging between agents with a versioned envelope (internal protocol, A2A compatible when suitable).

  • Validate the envelope (version, from, to, intent, payload, trace)
  • Check OpenFGA authorization can_message
  • Deliver to the recipient inbox

2. Position in the architecture and interactions​

  • Callers: Running agents (agent role), external A2A gateways.
  • Execution path: Asynchronous: NATS publication, read via inbox.
  • Every interaction goes through the Control Plane API v1 (/v1) behind the API Gateway (D-14).

3. Open source component and developed part​

  • Open source: NATS JetStream, A2A
  • Developed: Versioned envelope, authorization, A2A bridge.
  • External integration through an adapter eai/integrations/<system>.py with an in-process fallback when the URL is not configured.

4. Data model​

Tables (schema eai, tenant_id RLS):

  • eai.a2a_messages

Common columns: id uuid, tenant_id uuid NOT NULL, created_at, updated_at; RLS policy current_setting('app.tenant_id', true)::uuid.

5. Contract​

  • Applied contract: execution-contract (trace) + A2A envelope v1
  • JSON Schema: contracts/v1/execution-contract.schema.json
  • Key fields: envelope_version, from_agent, to_agent, intent, payload, trace_id
  • Validation: POST /v1/contracts/{name}/validate; manifest apply: POST /v1/manifests/apply.

6. API endpoints​

  • POST /v1/a2a/messages
  • GET /v1/a2a/inbox

Request POST /v1/a2a/messages:

{
"envelope_version": "1",
"from_agent": "agt_support",
"to_agent": "agt_billing",
"intent": "request",
"payload": {
"invoice": "F-2024-11"
}
}

Response:

{
"message_id": "msg_88",
"status": "queued"
}

7. SDK examples​

Python:

from enterprise_ai import EnterpriseAI

client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
client.a2a.send("agt_billing", {"invoice": "F-2024-11"}, type="request")
inbox = client.a2a.inbox("agt_billing", unread=True)

TypeScript:

import { EnterpriseAI } from "@enterprise-ai/sdk";

const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
await client.a2a.send({ to: "agent:billing", type: "request", payload: {} });

Java:

EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
client.a2a().send(Map.of("to", "agt_billing", "type", "request", "payload", payload));

Go:

c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
c.A2A.Send(ctx, map[string]any{"to": "agt_billing", "type": "request"})

8. Configuration​

  • Environment variables: EAI_NATS_URL, EAI_DATABASE_URL
  • Helm values keys: nats.enabled, controlPlane.config.EAI_NATS_URL

9. Security controls​

  • DLP on the payload before delivery
  • No cross-tenant messages
  • Every request carries the tenant resolved from the credential; PostgreSQL RLS
  • Every mutation and policy decision writes a hash-chained audit event

10. Observability​

  • Prometheus metrics: eai_a2a_messages_total{intent}, eai_a2a_delivery_latency_seconds
  • Traces: OpenTelemetry spans with GenAI semantic conventions (gen_ai.operation.name, gen_ai.agent.id, gen_ai.tool.name), attributes eai.tenant_id, eai.run_id, traceparent propagation.
  • Audit actions: a2a.send

11. FinOps units​

  • Message count and volume.
  • Emitted as Usage Event (POST /v1/finops/usage) with tenant, project, agent and run.

12. Failure modes and resilience​

  • Deduplication by message_id
  • JetStream retention and redelivery
  • Normalized errors (error envelope, message_i18n en/fr)

13. Standalone adoption (client of a client)​

  • enterprise_ai.agent + Control Plane + NATS.
  • SDK: enterprise_ai.agent (AgentsClient, RunsClient, SessionsClient)
  • Minimal deployment: Helm chart with controlPlane.enabled=true and PostgreSQL; disabled external components use their in-process fallback.

14. Acceptance tests​

  1. Unknown envelope version -> 422
  2. Unauthorized recipient -> 403
  3. Cross-tenant access refused
  4. Error returned in fr with Accept-Language: fr