A2A Integration
How to set up agent-to-agent (A2A) communication — discover CodeSpar agents, submit tasks, poll for results, and configure outbound A2A policies.
A2A Integration
Agent-to-Agent (A2A) is an open protocol that lets external AI agents interact with CodeSpar agents programmatically. A CI agent can ask CodeSpar to investigate a build failure. A monitoring agent can request a rollback. Any A2A-compatible agent can discover and invoke CodeSpar skills over HTTP.
What is A2A
A2A is a standardized protocol for agent interoperability. Each agent publishes a descriptor at /.well-known/agent.json that lists its capabilities (skills). Other agents discover these skills, submit tasks, and poll for results — all over REST.
CodeSpar implements A2A as both a server (external agents call CodeSpar) and a client (CodeSpar calls external agents).
Discovering CodeSpar Agents
Every CodeSpar instance exposes an agent descriptor at:
Example response:
Submitting a Task
To invoke a CodeSpar skill, send a POST to the /a2a/tasks endpoint with the skill ID and input parameters:
Response:
Task Fields
| Field | Required | Description |
|---|---|---|
skillId | Yes | The skill to invoke (from agent.json) |
input | Yes | Parameters matching the skill's inputSchema |
callbackUrl | No | URL to receive the result when the task completes |
priority | No | low, medium, high (default: medium) |
metadata | No | Arbitrary key-value pairs passed through to the result |
Polling for Results
If you did not provide a callbackUrl, poll the task status:
Response while in progress:
Response when complete:
Task Statuses
| Status | Description |
|---|---|
accepted | Task received, queued for processing |
in_progress | Agent is actively working on the task |
completed | Task finished successfully, result contains output |
failed | Task failed, error contains details |
rejected | Task rejected by policy (budget, allowlist, permissions) |
If you provided a callbackUrl, CodeSpar sends a POST with the completed task payload to that URL when the task finishes.
Outbound A2A: Calling External Agents
CodeSpar can also call external A2A-compatible agents. Configure allowed external agents in your environment:
Once configured, CodeSpar agents can delegate tasks to external agents. For example, the Incident Agent can ask an external monitoring agent for additional metrics when investigating a failure.
Registering External Agents via API
You can also register external agents dynamically:
A2A Policy: Budget, Allowlist, Approval Rules
Control A2A behavior with policy rules to prevent runaway costs and unauthorized interactions.
Environment Variables
| Variable | Default | Description |
|---|---|---|
A2A_ENABLED | false | Enable A2A server endpoints |
A2A_ALLOWED_AGENTS | "" | Comma-separated URLs of trusted external agents |
A2A_DISCOVERY_ON_STARTUP | true | Auto-discover skills from allowed agents on boot |
A2A_OUTBOUND_TIMEOUT_MS | 30000 | Timeout for outbound A2A calls |
A2A_MAX_TASKS_PER_HOUR | 100 | Rate limit: max inbound A2A tasks per hour |
A2A_MAX_COST_PER_TASK_USD | 1.00 | Budget cap per individual A2A task |
A2A_MAX_DAILY_BUDGET_USD | 50.00 | Daily budget cap for all A2A tasks |
A2A_REQUIRE_APPROVAL_SKILLS | "" | Comma-separated skill IDs that require human approval |
ABAC Policy Example
Add an A2A policy rule in your project's YAML policy file:
Approval Flow for A2A Tasks
When an A2A task triggers an approval requirement:
- CodeSpar creates an approval request and notifies the team via connected channels
- The A2A task status moves to
pending_approval - Team members approve or deny via channel (Slack, WhatsApp, etc.)
- Once approved, the task resumes. If denied or expired, the task is rejected.
- The external agent receives the final status via callback or polling.
Example: External CI Agent Investigates a Build Failure
A common A2A scenario: your CI system has an agent that detects build failures and asks CodeSpar to investigate.
Step 1: CI Agent Discovers CodeSpar
The CI agent finds the investigate-build-failure skill.
Step 2: CI Agent Submits a Task
Step 3: CodeSpar Investigates
The Incident Agent activates, fetches workflow logs, correlates with recent commits, and produces a root cause analysis.
Step 4: CI Agent Receives the Result
CodeSpar posts to the callback URL:
The CI agent can then update the build status, post a comment on the commit, or trigger a rerun after the fix is merged.
Next Steps
- Webhook Monitoring -- set up GitHub webhooks for real-time events
- Approval System -- configure approval rules and quorum
- Plugin System -- extend CodeSpar with custom plugins
- API Reference -- full API endpoint documentation