Skip to Content
Native FeaturesA2A Protocol

A2A Protocol

TOS implements the Agent-to-Agent (A2A) Protocol for off-chain agent communication, seamlessly integrated with on-chain settlement capabilities.

Implementation Status

Status: 100% Implemented

Both the A2A Protocol Layer (off-chain) and On-Chain Settlement Layer are fully implemented.

ComponentItemsStatus
Core Data Structures11Complete
Agent Card7Complete
Security Schemes17Complete
Service Operations11Complete
Request/Response Types12Complete
Push Notification8Complete
TOS Extensions9Complete
Error Types19Complete
Total133Complete

Architecture

┌─────────────────────────────────────────────────────────────┐ │ Client / Orchestrator │ ├─────────────────────────────────────────────────────────────┤ │ ┌───────────────────────────────────────────────────────┐ │ │ │ A2A Protocol Layer (Off-Chain) │ │ │ │ - Agent Discovery (Agent Card) │ │ │ │ - Task Lifecycle Management (11 Operations) │ │ │ │ - Message & Streaming Communication │ │ │ │ - Push Notifications │ │ │ │ - Standard Security (OAuth2, API Key, mTLS) │ │ │ │ - TOS Signature Authentication (Extension) │ │ │ └───────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌───────────────────────────────────────────────────────┐ │ │ │ Agent Account Protocol (On-Chain, Optional) │ │ │ │ - AgentAccountMeta (owner, controller, session_key) │ │ │ │ - SessionKey scope enforcement │ │ │ │ - Energy pool fee management │ │ │ │ - On-chain settlement (escrow) │ │ │ └───────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌───────────────────────────────────────────────────────┐ │ │ │ TOS Blockchain │ │ │ └───────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────┘

Key Features

Agent Discovery

Agents publish an Agent Card at a well-known URL for discovery:

GET https://{domain}/.well-known/agent-card.json

The Agent Card describes:

  • Supported interfaces and protocol bindings
  • Security schemes (OAuth2, API Key, TOS Signature)
  • Agent capabilities and skills
  • TOS identity (optional extension)

Task Management

11 standard A2A operations for task lifecycle:

OperationDescription
SendMessageSend a message to the agent
SendStreamingMessageStreaming version with real-time updates
GetTaskGet current task state
ListTasksList tasks with filtering
CancelTaskCancel a running task
SubscribeToTaskSubscribe to task updates (SSE)
Set/Get/List/DeleteTaskPushNotificationConfigManage push notifications
GetExtendedAgentCardGet authenticated agent card

Protocol Bindings

BindingTransportFormatUse Case
JSON-RPC 2.0HTTP POSTJSONDefault, web-friendly
gRPCHTTP/2ProtobufHigh-performance
HTTP+JSONRESTJSONSimple integration

Streaming Support

TransportEndpointFormat
HTTP SSEPOST /v1/message:streamServer-Sent Events
WebSocketGET /a2a/wsJSON-RPC 2.0

Security Schemes

TOS supports all standard A2A security schemes plus blockchain-native authentication:

Standard Security

SchemeDescription
API KeySimple API key in header/query/cookie
HTTP AuthBearer token or Basic auth
OAuth 2.0Full OAuth2 flows support
OpenID ConnectOIDC authentication
mTLSMutual TLS certificates

TOS Signature (Extension)

Blockchain-based authentication using TOS Agent Accounts:

pub struct TosSignature { pub signer: TosSignerType, // Owner, Controller, or SessionKey pub value: String, // Hex-encoded signature pub timestamp: u64, // Unix timestamp pub nonce: u64, // Replay protection pub session_key_id: Option<u64>, }

Security Measures:

  • Nonce replay protection (single-use within TTL)
  • Timestamp validation (configurable TTL, default 5 min)
  • Bounded nonce cache (10,000 entries, LRU eviction)
  • Verify-before-store (prevents memory exhaustion DoS)

TOS Extensions

TOS extends the A2A protocol with optional blockchain features:

On-Chain Settlement

Link A2A tasks to on-chain escrow for trustless payment:

pub struct TosTaskAnchor { pub escrow_id: u64, pub agent_account: PublicKey, pub settlement_status: SettlementStatus, } pub enum SettlementStatus { None, EscrowLocked, Claimed, Refunded, Disputed, }

Settlement Operations:

  • CreateTaskEscrow - Lock funds for a task
  • ClaimTaskReward - Agent claims payment on completion
  • ReclaimEscrowTimeout - Client reclaims after timeout

Agent Identity

On-chain identity verification for agents:

pub struct TosAgentIdentity { pub agent_account: PublicKey, pub controller: PublicKey, pub reputation_score_bps: Option<u32>, pub identity_proof: Option<TosIdentityProof>, }

HTTP Endpoints

Primary Endpoints (Unversioned)

MethodEndpointOperation
GET/.well-known/agent-card.jsonGet Agent Card (PUBLIC)
POST/message:sendSendMessage
POST/message:streamSendStreamingMessage (SSE)
GET/tasksListTasks
GET/tasks/{id}GetTask
POST/tasks/{id}:cancelCancelTask
POST/tasks/{id}:subscribeSubscribeToTask (SSE)
GET/a2a/wsWebSocket Streaming

Versioned Endpoints (A2A v1.0 Compatible)

All endpoints also available under /v1/ prefix for A2A v1.0 compatibility.


Usage Example

SendMessage Request

{ "jsonrpc": "2.0", "id": "req-001", "method": "SendMessage", "params": { "message": { "messageId": "msg-001", "role": "user", "parts": [{ "text": "Swap 100 USDT for TOS" }] }, "configuration": { "acceptedOutputModes": ["text/plain"], "blocking": false } } }

HTTP Headers:

Content-Type: application/json Authorization: Bearer <token> a2a-version: 1.0

Task Response

{ "jsonrpc": "2.0", "id": "req-001", "result": { "task": { "id": "task-abc123", "contextId": "ctx-xyz789", "status": { "state": "submitted", "timestamp": "2024-01-08T12:00:00Z" }, "artifacts": [], "history": [] } } }

With TOS Settlement

{ "jsonrpc": "2.0", "id": "req-002", "method": "SendMessage", "params": { "message": { "messageId": "msg-002", "taskId": "task-abc123", "role": "user", "parts": [{ "text": "Swap 100 USDT for TOS" }] }, "metadata": { "tosSettlement": { "maxCost": 5000000000, "currency": "TOS", "escrowHash": "0xabc123...def456", "agentAccount": "tos1abc...xyz" } } } }

Agent Card Example

{ "protocolVersion": "1.0", "name": "TOS Trading Agent", "description": "Automated DeFi trading with on-chain settlement", "version": "1.0.0", "supportedInterfaces": [ { "url": "https://agent.example.com/a2a", "protocolBinding": "JSONRPC" }, { "url": "https://agent.example.com/a2a/grpc", "protocolBinding": "GRPC" } ], "capabilities": { "streaming": true, "pushNotifications": true, "tosOnChainSettlement": true }, "securitySchemes": { "bearerAuth": { "httpAuthSecurityScheme": { "scheme": "bearer", "bearerFormat": "JWT" } }, "tosSignature": { "tosSignatureSecurityScheme": { "chainId": 1337, "allowedSigners": ["owner", "controller", "session-key"] } } }, "skills": [ { "id": "swap", "name": "Token Swap", "description": "Execute token swaps on DEXes", "tags": ["defi", "swap", "trade"], "examples": ["Swap 100 USDT for TOS"], "tosBaseCost": 1000000 } ], "tosIdentity": { "agentAccount": "tos1abc...xyz", "controller": "tos1def...uvw", "reputationScoreBps": 8500 } }

Error Codes

Standard JSON-RPC Errors

CodeNameDescription
-32700Parse ErrorInvalid JSON
-32600Invalid RequestInvalid request object
-32601Method Not FoundMethod does not exist
-32602Invalid ParamsInvalid parameters
-32603Internal ErrorInternal server error

A2A Protocol Errors

CodeNameDescription
-32001TaskNotFoundErrorTask does not exist
-32002TaskNotCancelableErrorTask cannot be cancelled
-32003PushNotificationNotSupportedErrorPush not supported
-32004UnsupportedOperationErrorOperation not supported

TOS Extension Errors

CodeNameDescription
-32100TosIdentityVerificationFailedAgent account invalid
-32101TosSignatureInvalidSignature verification failed
-32102TosSessionKeyExpiredSession key expired
-32103TosAccountFrozenAgent account is frozen
-32104TosEscrowFailedEscrow operation failed

A2A v1.0 Compatibility

TOS A2A is fully compatible with the A2A Protocol v1.0  specification:

  • All core data structures follow the official A2A schema
  • All 11 A2A operations are supported
  • Standard security schemes (OAuth2, API Key, OpenID Connect, mTLS) supported
  • TOS extensions are clearly marked and optional

Extension Mechanism: TOS-specific fields use #[serde(skip_serializing_if = "Option::is_none")] and are safely ignored by non-TOS implementations.


Last updated on