Skip to content

A2A (Agent-to-Agent) Protocol ​

The Agent-to-Agent (A2A) gateway in @latticedx/plugin-dxos-ai standardizes how external orchestrators discover LatticeDX agent capabilities and exchange stateful tasks over JSON-RPC 2.0. Implemented in a2a-gateway.js as an HTTP middleware layer inside the NocoBase host, it binds agent delegation directly to PostgreSQL FORCE ROW LEVEL SECURITY tenant isolation, RBAC role checks, and audit logging in latticeAiAuditLogs.

While the MCP Gateway exposes discrete tools, resources, and prompts to a connected client, A2A defines task-level delegation between autonomous agents. Every tasks/send, tasks/get, and tasks/cancel call persists state in latticeA2aTasks scoped to the caller's organizationId, and direct REST CRUD on that collection is blocked.

Agent Card Discovery ​

The gateway publishes its Agent Card at two discovery endpoints so external clients and peer orchestrators can inspect supported skills and authentication requirements before submitting work. Both routes accept only GET and HEAD, set Cache-Control: no-store and X-Content-Type-Options: nosniff, and bypass the NocoBase { data } envelope (withoutDataWrapping = true).

GET/.well-known/agent-card.json
Public Discovery
Returns the standard A2A Agent Card declaring the JSON-RPC URL, Bearer authentication scheme, and 7 agent skills.
GET/api/dxos-a2a/agent-card.json
Public Discovery
Prefixed discovery route under /api for reverse proxies that forward only API traffic.

resolveSafeCardEndpointUrl resolves the advertised /api/dxos-a2a endpoint url in order of precedence from DXOS_A2A_PUBLIC_URL, DXOS_PUBLIC_URL, and NOCOBASE_PUBLIC_URL, falling back to validated X-Forwarded-Proto and X-Forwarded-Host request headers. When deployed behind Nginx (10-lattice-public-routes.sh) or Caddy, /.well-known/agent-card.json is proxied directly with caching disabled.

Agent Card Schema Fields
ParameterTypeDefaultDescription
namerequired
stringLatticeDX Enterprise A2A GatewayHuman-readable gateway identifier.
urlrequired
string—Absolute JSON-RPC 2.0 endpoint URL ending in /api/dxos-a2a.
versionrequired
string0.4.2Running version of @latticedx/plugin-dxos-ai.
capabilities.streamingrequired
booleanfalseIndicates whether SSE streaming is enabled on A2A task calls.
capabilities.pushNotificationsrequired
booleanfalseIndicates whether asynchronous webhook push notifications are enabled.
capabilities.stateTransitionHistoryrequired
booleantruePersists full message and state transition history inside latticeA2aTasks.
authentication.schemesrequired
string[]['bearer']Requires Bearer JWT authentication for all JSON-RPC task operations.
skillsrequired
AgentSkill[]—Catalog of 7 skills mapped from A2A_AGENT_CATALOG with tags, inputModes, and outputModes.

Published Agent Skills ​

Each entry in skills maps to a starter AI profile (see AI Overview & Profiles for full tool permissions). During task execution, the gateway also checks latticeAiProfiles within the caller's organizationId so tenant-specific systemPrompt, modelName, and role locks take effect.

Skill IDDisplay NameTagsDefault Authorized Caller Roles
dxos-coordinatorDX-OS Multi-Agent Coordinatorcoordination, orchestration, radar, routingroot, admin, ldx_admin, ldx_director, ldx_manager, ldx_employee, ldx_warehouse, ldx_dispatcher, ldx_driver
dxos-architectDX-OS System & App Architectarchitecture, app-builder, schema, portal, workflowroot, admin (locked via isAdminBuilder)
dxos-opsDX-OS Cold-Chain & IoT Opscold-chain, iot, orion-ld, incidentsroot, admin, ldx_admin, ldx_director, ldx_manager, ldx_employee, ldx_warehouse
dxos-logisticsDX-OS Cold-Chain Logistics Dispatcherlogistics, fefo, dispatch, epodroot, admin, ldx_admin, ldx_director, ldx_manager, ldx_employee, ldx_warehouse, ldx_dispatcher, ldx_driver
dxos-workspaceDX-OS Services, Procurement & P.A.R.A. Assistantservices, procurement, para, knowledgeroot, admin, ldx_admin, ldx_director, ldx_manager, ldx_employee
dxos-operatorDX-OS Operations Executoroperations, it-ot, triage, executionroot, admin, ldx_admin, ldx_director, ldx_manager, ldx_operator, ldx_dispatcher, ldx_warehouse
dxos-analystDX-OS Enterprise Analystanalytics, bi, impact-graph, diagnosticsroot, admin, ldx_admin, ldx_director, ldx_manager, ldx_employee

JSON-RPC 2.0 Endpoint and Task Lifecycle ​

All task submission, status polling, and cancellation requests target POST /api/dxos-a2a using JSON-RPC 2.0. Non-POST requests return HTTP 405, and unauthenticated calls return HTTP 401 with WWW-Authenticate: Bearer realm="LatticeDX-A2A", error="invalid_token" while logging an audit denial.

POST/api/dxos-a2a
Bearer JWTtasks/send | tasks/get | tasks/cancel
Single JSON-RPC 2.0 endpoint managing local agent handoffs and external A2A peer delegation.

Task State Machine (A2A_VALID_STATUSES) ​

Every task row in latticeA2aTasks stores status, conversation history (messagesJson), output artifactsJson, metadataJson, and errorJson. Six states are defined in A2A_VALID_STATUSES:

StateCategoryOperational Meaning
submittedActiveInitial state persisted to latticeA2aTasks before agent or peer execution begins.
workingActiveTask accepted for asynchronous execution (async: true or blocking: false).
input-requiredActiveTarget agent or remote peer requires additional user input or approval before finishing.
completedTerminalExecution succeeded and produced response messages and structured artifacts.
failedTerminalLocal execution error, remote HTTP/JSON-RPC error, or peer timeout (PEER_TIMEOUT).
canceledTerminalCanceled by the task creator or an administrator prior to reaching a terminal state.

Once a task enters any state in A2A_TERMINAL_STATES (completed, failed, canceled), subsequent tasks/cancel calls fail with HTTP 409 and JSON-RPC error code -32004.

JSON-RPC params Reference ​

Parameters for tasks/send, tasks/get, and tasks/cancel
ParameterTypeDefaultDescription
id / taskId
stringa2a_<uuid>Task identifier matching ^[a-zA-Z0-9._:-]{1,128}$. Required for tasks/get and tasks/cancel.
targetAgentId
stringdxos-coordinatorTarget agent ID (defaults to external-peer when peerUrl is supplied). Aliases: agentId, metadata.targetAgentId.
sourceAgentId
stringuser:<username>Calling agent or user identifier recorded on the task.
messagerequired
object—Object { role, parts } with type=text (max 16000 chars) or type=data. Plain prompt, text, or input strings are also accepted.
peerUrl
string—HTTPS endpoint of an external A2A peer for outbound delegation after SSRF validation.
idempotencyKey
string—Per-organization deduplication key (max 255 chars); returns the existing task if authorized.
async / blocking
booleanfalse / trueSet async: true or blocking: false to return immediately in working state for local tasks.
historyLength
integer—Used by tasks/get to slice the trailing N entries of messages and history.
reason
stringCanceled by callerUsed by tasks/cancel (max 300 chars), stored under metadataJson.cancelReason.

Interoperability Examples ​

The examples below show Agent Card discovery, sending a task to dxos-ops with an idempotency key, inspecting and canceling a task, and delegating to an external A2A peer.

bash
# 1. Discover Agent Card skills
curl -s https://lattice.example.com/.well-known/agent-card.json | jq '.skills[].id'

# 2. Submit an idempotent task to dxos-ops
curl -s -X POST https://lattice.example.com/api/dxos-a2a \
  -H "Authorization: Bearer $LATTICE_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": "req-101",
    "method": "tasks/send",
    "params": {
      "id": "task-coldchain-401",
      "targetAgentId": "dxos-ops",
      "idempotencyKey": "idem-coldchain-401",
      "message": {
        "role": "user",
        "parts": [
          { "type": "text", "text": "Inspect CT-02 cold room temperature thresholds and summarize open alarms." },
          { "type": "data", "data": { "warehouseCode": "HUB-CT", "severity": "high" } }
        ]
      },
      "metadata": { "portalSlug": "incidents" }
    }
  }'

Security Boundaries and Failure Modes ​

The A2A gateway enforces strict tenant, role, network, and payload checks before writing to latticeA2aTasks or invoking local and remote execution paths.

Control LayerRuntime Enforcement in a2a-gateway.jsHTTP / JSON-RPC Error
Tenant spoofing protectionassertNoCrossOrgSpoofing validates every organizationId in X-Organization-Id, X-Org-Id, and params against the caller's latticeEmployees membership.403 / -32003 (A2A_CROSS_ORG_FORBIDDEN)
Admin builder role lockauthorizeTargetAgent restricts dxos-architect strictly to root and admin; disabled profiles (enabled: false) are rejected.403 / -32003 (A2A_ROLE_FORBIDDEN)
Task ownership isolationauthorizeExistingTaskAccess prevents non-admin users from reading, replaying via idempotencyKey, or canceling tasks created by other users.403 / -32003 (A2A_TASK_FORBIDDEN)
Outbound peer SSRF guardassertSafePeerUrl blocks embedded URL credentials, internal suffixes (localhost, .local, .internal), non-canonical decimal/octal/hex hosts, private/link-local IPv4/IPv6 ranges, cloud metadata hosts, and re-validates resolved DNS IPs; outbound fetch sets redirect: 'error'.400 / -32602 (A2A_PEER_URL_UNSAFE)
Outbound PII and header scrubbingdelegateToExternalA2aPeer applies redactPiiDeep to outbound message and metadata, while sanitizeOutboundHeaders strips authorization, cookie, and x-api-key.Applied automatically
Prototype pollution guardassertNoPrototypePollution and cloneSafePlain reject __proto__, constructor, and prototype keys and enforce a nesting cap of 24 levels.400 / -32602 (A2A_PROTOTYPE_POLLUTION)
Direct collection CRUD blockdxosAiMemoryAndA2aScope blocks direct REST and Chart queries against latticeA2aTasks for all non-root callers.403 (DXOS_A2A_DIRECT_CRUD_FORBIDDEN)

latticeA2aTasks Storage and Peer Timeout Behavior ​

Each task record in latticeA2aTasks is uniquely indexed on (organizationId, taskId) (uidx_lattice_a2a_tasks_org_task) alongside an idempotency lookup index (idx_lattice_a2a_tasks_org_idem). When delegating to an external peer through delegateToExternalA2aPeer, timeout values are clamped between 500ms and 120000ms (defaulting to 15000ms). If the remote peer times out or returns an HTTP/JSON-RPC failure, the task transitions to failed with a PII-redacted error message capped at 400 characters (PEER_TIMEOUT, PEER_HTTP_<status>, or PEER_RPC_ERROR).

If no live LLM service is configured or available, executeDefaultLocalAgent falls back to governed-local-handoff, returning a PII-redacted receipt artifact and recording the outcome in latticeAiAuditLogs under channel: 'a2a'.

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)