Skip to content

a2a_protocol_core

Pure A2A (Agent-to-Agent) protocol domain logic, completely transport agnostic.

const A2A_PROTOCOL_VERSION: &str = ;

A2A Protocol Version

type A2AResult = Result<T, A2AError>;
type A2AMethodHandler = Arc<dyn Fn + Send + Sync>;

A2A Method Handler function type

Handlers receive a JSON-RPC request and return a JSON-RPC response. All A2A protocol logic is handled through JSON-RPC 2.0 messages.

type A2ANotificationHandler = Arc<dyn Fn + Send + Sync>;

A2A Notification Handler function type

Notification handlers receive notifications and perform side effects without returning responses (fire-and-forget).

type MessageSendParams = SendMessageRequest;
type MessageSendResponse = SendMessageResponse;
type TaskCancelParams = CancelTaskRequest;
type TaskGetParams = GetTaskRequest;
type TaskListParams = ListTasksRequest;
type TaskListResult = ListTasksResponse;

A2A Transport trait

Defines the interface for sending A2A protocol messages over various transport mechanisms. Implementations handle the actual network communication while the protocol core handles the A2A semantics.

  • Transport Agnostic: Works with HTTP, WebSocket, gRPC, etc.
  • JSON-RPC Foundation: Uses JSON-RPC 2.0 message types
  • Async Compatible: Supports both sync and async implementations
  • Error Transparent: Transport errors are mapped to A2A errors
use a2a_protocol_core::{A2ATransport, JsonRpcRequest, JsonRpcResponse, JsonRpcNotification, A2AResult};
use serde_json::json;
// Mock transport implementation
struct MockTransport;
impl A2ATransport for MockTransport {
async fn send_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse> {
// Implementation sends request over network
Ok(JsonRpcResponse::success(request.id, json!({"pong": true})))
}
async fn send_notification(&self, notification: JsonRpcNotification) -> A2AResult<()> {
// Implementation sends notification (fire-and-forget)
Ok(())
}
async fn health_check(&self) -> A2AResult<()> {
// Check if transport is available
Ok(())
}
}

Required / Provided Methods

async fn send_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>

Send a JSON-RPC request and wait for response

This method sends a request to a remote agent and waits for the response. The transport implementation handles the actual network communication, serialization, and correlation of requests with responses.

  • request: The JSON-RPC 2.0 request to send
  • Ok(JsonRpcResponse): The response from the remote agent
  • Err(A2AError): Transport or protocol error
async fn send_notification(&self, notification: JsonRpcNotification) -> A2AResult<()>

Send a JSON-RPC notification (fire-and-forget)

This method sends a notification to a remote agent without waiting for a response. Notifications are used for logging, metrics, events, and other operations where the sender doesn’t need confirmation.

  • notification: The JSON-RPC 2.0 notification to send
  • Ok(()): Notification was sent successfully
  • Err(A2AError): Transport error occurred
async fn health_check(&self) -> A2AResult<()>

Check if the transport is available and healthy

This method verifies that the transport can communicate with remote agents. It’s used for health checks, circuit breakers, and load balancing decisions.

  • Ok(()): Transport is healthy and available
  • Err(A2AError): Transport is unavailable or unhealthy
fn get_metadata(&self) -> HashMap<String, Value>

Get transport-specific metadata

This method returns metadata about the transport implementation, such as connection info, capabilities, or configuration details.

A map of metadata key-value pairs

fn transport_type(&self) -> &''static str

Get the transport type identifier

Returns a string identifying the transport type (e.g., “http”, “websocket”). This is used for logging, monitoring, and debugging.

A2A Transport Factory trait

Factory for creating transport instances for different agents or endpoints. This enables connection pooling, load balancing, and dynamic transport configuration.

Associated Types

  • type Transport — Transport type created by this factory

Required / Provided Methods

async fn create_transport(&self, agent_id: &str, endpoint: &str, config: Option<HashMap<String, Value>>) -> A2AResult<<Self as ?>::Transport>

Create a transport instance for the specified agent

  • agent_id: Target agent identifier
  • endpoint: Agent endpoint URL or connection string
  • config: Optional transport-specific configuration
  • Ok(Transport): Successfully created transport
  • Err(A2AError): Failed to create transport
async fn get_transport(&self, agent_id: &str, endpoint: &str) -> A2AResult<<Self as ?>::Transport>

Get or create cached transport for agent

This method may reuse existing connections for better performance.

  • agent_id: Target agent identifier
  • endpoint: Agent endpoint URL or connection string
  • Ok(Transport): Transport ready for use
  • Err(A2AError): Failed to get/create transport
async fn remove_transport(&self, agent_id: &str) -> A2AResult<()>

Remove cached transport for agent

Forces creation of a new transport on next request. Useful for handling connection failures or configuration changes.

fn get_config(&self) -> HashMap<String, Value>

Get factory configuration

Trait for agent discovery.

Required / Provided Methods

fn agent_authenticated_extended_card(&self, params: AuthenticatedExtendedCardParams) -> A2AResult<AuthenticatedExtendedCardResult>

Enhanced Task Storage Service Interface

Defines the contract for task storage operations with proper A2A protocol support for context-based operations (1 context : N tasks relationship).

Required / Provided Methods

fn store_task(&self, task: Task) -> A2AResult<()>

Store a new or updated task

fn get_task(&self, task_id: &str) -> A2AResult<Option<Task>>

Retrieve a task by ID

fn update_task(&self, task: Task) -> A2AResult<()>

Update an existing task

fn list_tasks(&self) -> A2AResult<Vec<Task>>

List all tasks (for tasks/list method)

fn remove_task(&self, task_id: &str) -> A2AResult<bool>

Remove a task (if needed for cleanup)

fn task_exists(&self, task_id: &str) -> A2AResult<bool>

Check if a task exists

fn get_tasks_by_context(&self, context_id: &str) -> A2AResult<Vec<Task>>

Get all tasks within a specific context (conversation)

This is the key method for A2A protocol compliance - allows retrieving all tasks that belong to the same conversation context.

fn get_latest_task_in_context(&self, context_id: &str) -> A2AResult<Option<Task>>

Get the latest (most recently created) task in a context

Useful for conversation continuity and determining the most recent task state within a conversation.

fn get_context_history(&self, context_id: &str) -> A2AResult<Vec<Message>>

Get conversation history from all tasks in a context

Aggregates message history from all tasks in a conversation context for LLM context management as specified in A2A protocol.

fn get_or_create_context(&self, context_id: &str) -> A2AResult<ConversationContext>

Get or create conversation context

Manages conversation context lifecycle - creates new context if it doesn’t exist, returns existing context otherwise.

fn update_context_activity(&self, context_id: &str) -> A2AResult<()>

Update context activity (called when new task is added)

Updates the conversation context metadata when tasks are added to track conversation lifecycle.

fn list_contexts(&self) -> A2AResult<Vec<ConversationContext>>

List all conversation contexts

Returns all active conversation contexts for management/debugging.

Agent Capabilities (v1.0)

Fields

FieldTypeDescription
streamingbool
push_notificationsbool
extensionsOption&lt;Vec&lt;AgentExtension&gt;&gt;
extended_agent_cardbool

Agent Card — v1.0 top-level metadata object.

Fields

FieldTypeDescription
nameString
descriptionOption&lt;String&gt;
versionOption&lt;String&gt;
supported_interfacesOption&lt;Vec&lt;AgentInterface&gt;&gt;
capabilitiesOption&lt;AgentCapabilities&gt;
skillsVec&lt;AgentSkill&gt;
default_input_modesOption&lt;Vec&lt;String&gt;&gt;
default_output_modesOption&lt;Vec&lt;String&gt;&gt;
security_schemesOption&lt;HashMap&lt;String, SecurityScheme&gt;&gt;
security_requirementsOption&lt;Vec&lt;SecurityRequirement&gt;&gt;
signaturesOption&lt;Vec&lt;AgentCardSignature&gt;&gt;
icon_urlOption&lt;String&gt;
providerOption&lt;AgentProvider&gt;
documentation_urlOption&lt;String&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;

Methods

fn new<impl Into<String>>(name: impl Into) -> Self

Minimal card with just a name.

fn with_capability<impl Into<String>, impl Into<String>>(self, method: impl Into, description: impl Into) -> Self

Register a method capability on this agent card.

Stores the method name and description in the card’s pf:methods metadata map. Used by A2AProtocol::register_method to keep the agent card in sync with the method registry.

fn supports_method(&self, method: &str) -> bool
fn get_method_description(&self, method: &str) -> Option<String>
fn add_skill(self, skill: AgentSkill) -> Self
fn get_skill(&self, skill_id: &str) -> Option<&AgentSkill>
fn get_skills_by_input_mode(&self, input_mode: &str) -> Vec<&AgentSkill>
fn supports_structured_skills(&self) -> bool

JWS signature for agent card integrity.

Fields

FieldTypeDescription
protectedString
signatureString
headerOption&lt;serde_json::Value&gt;

Agent Extension (v1.0)

Fields

FieldTypeDescription
uriString
descriptionOption&lt;String&gt;
requiredbool
paramsOption&lt;serde_json::Value&gt;

Agent Interface (v1.0) — how to reach this agent.

Fields

FieldTypeDescription
urlString
protocol_bindingString
tenantOption&lt;String&gt;
protocol_versionOption&lt;String&gt;

Agent Provider (v1.0)

Fields

FieldTypeDescription
urlOption&lt;String&gt;
organizationString

Agent Skill (v1.0)

Fields

FieldTypeDescription
idString
nameString
descriptionString
tagsOption&lt;Vec&lt;String&gt;&gt;
examplesOption&lt;Vec&lt;String&gt;&gt;
input_modesOption&lt;Vec&lt;String&gt;&gt;
output_modesOption&lt;Vec&lt;String&gt;&gt;
security_requirementsOption&lt;Vec&lt;SecurityRequirement&gt;&gt;

Methods

fn with_examples(self, examples: Vec<String>) -> Self
fn with_example<impl Into<String>>(self, example: impl Into) -> Self
fn with_tags(self, tags: Vec<String>) -> Self
fn supports_json_input(&self) -> bool

Methods

fn new(agent_card: AgentCard) -> Self
fn with_registry(agent_card: AgentCard, registry: A2AMethodRegistry) -> Self
fn agent_card(&self) -> &AgentCard
fn update_agent_card(&mut self, agent_card: AgentCard)
fn registry(&self) -> &A2AMethodRegistry
fn registry_mut(&mut self) -> &mut A2AMethodRegistry
fn register_method<F>(&mut self, method: &str, description: &str, handler: F)
where
F: Fn + Send + Sync + ?
fn register_notification<F>(&mut self, method: &str, description: &str, handler: F)
where
F: Fn + Send + Sync + ?
fn handle_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>
fn handle_notification(&self, notification: JsonRpcNotification) -> A2AResult<()>
fn handle_incoming(&self, incoming: JsonRpcIncoming) -> A2AResult<Option<JsonRpcResponse>>
fn get_capabilities(&self) -> Value
fn get_method_metadata(&self) -> HashMap<String, &MethodMetadata>
fn validate_request_params(&self, method: &str, params: &Value) -> A2AResult<()>
fn register_a2a_methods(&mut self, storage: Option<Arc<dyn TaskStorage>>)

Register all A2A v1.0 protocol methods.

async fn send_request<T>(&self, transport: &T, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>
async fn send_notification<T>(&self, transport: &T, notification: JsonRpcNotification) -> A2AResult<()>

A2A Method Registry

Central registry for A2A protocol methods and their handlers. Provides method registration, lookup, and validation functionality without any transport dependencies.

  • Pure Domain Logic: No transport or infrastructure concerns
  • JSON-RPC Foundation: All methods use JSON-RPC 2.0 message types
  • Thread Safe: Can be safely shared across multiple threads
  • Method Metadata: Rich metadata for discovery and documentation
use a2a_protocol_core::{A2AMethodRegistry, JsonRpcRequest, JsonRpcResponse, A2AError};
use serde_json::json;
use std::sync::Arc;
fn example() -> Result<(), A2AError> {
let mut registry = A2AMethodRegistry::new();
// Register a method handler
registry.register_method(
"ping",
"Simple ping method",
Arc::new(|request| {
Ok(JsonRpcResponse::success(request.id, json!({"pong": true})))
})
);
// Handle requests
let request = JsonRpcRequest::new(json!("req-123"), "ping".to_string(), json!({}));
let response = registry.handle_request(request)?;
Ok(())
}

Methods

fn new() -> Self

Create a new empty registry

fn with_agent_card(agent_card: AgentCard) -> Self

Create a registry with agent card

fn set_agent_card(&mut self, agent_card: AgentCard)

Set the agent card for this registry

fn agent_card(&self) -> Option<&AgentCard>

Get the agent card

fn register_method<impl Into<String>, impl Into<String>>(&mut self, method: impl Into, description: impl Into, handler: A2AMethodHandler)

Register a method handler

Registers a handler function for JSON-RPC requests to the specified method.

  • method: Method name (e.g., “ping”, “process_data”)
  • description: Human-readable description of the method
  • handler: Function that handles requests for this method
fn register_method_with_metadata<impl Into<String>, impl Into<String>>(&mut self, method: impl Into, description: impl Into, parameters: Option<Value>, returns: Option<Value>, handler: A2AMethodHandler)

Register a method handler with metadata

Registers a method handler with detailed parameter and return type information.

fn register_notification<impl Into<String>, impl Into<String>>(&mut self, method: impl Into, description: impl Into, handler: A2ANotificationHandler)

Register a notification handler

Registers a handler function for JSON-RPC notifications (fire-and-forget).

  • method: Method name (e.g., “log.info”, “metric.counter”)
  • description: Human-readable description of the notification
  • handler: Function that handles notifications for this method
fn handle_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>

Handle a JSON-RPC request

Looks up the method handler and executes it with the request.

  • request: The JSON-RPC 2.0 request to handle
  • Ok(JsonRpcResponse): Success response from method handler
  • Err(A2AError): Method not found or handler error
fn handle_notification(&self, notification: JsonRpcNotification) -> A2AResult<()>

Handle a JSON-RPC notification

Looks up the notification handler and executes it.

  • notification: The JSON-RPC 2.0 notification to handle
  • Ok(()): Notification handled successfully
  • Err(A2AError): Method not found or handler error
fn has_method(&self, method: &str) -> bool

Check if method is registered

fn has_notification(&self, method: &str) -> bool

Check if notification is registered

fn get_method_metadata(&self, method: &str) -> Option<&MethodMetadata>

Get method metadata

fn list_methods(&self) -> Vec<String>

List all registered methods

fn list_notifications(&self) -> Vec<String>

List all registered notifications

fn get_all_metadata(&self) -> &HashMap<String, MethodMetadata>

Get all method metadata

fn unregister_method(&mut self, method: &str) -> bool

Unregister a method

fn unregister_notification(&mut self, method: &str) -> bool

Unregister a notification

fn clear(&mut self)

Clear all registrations

fn stats(&self) -> RegistryStats

Get registry statistics

Method metadata

Contains information about a registered method including its description, parameters, and capabilities.

Fields

FieldTypeDescription
nameString
descriptionString
parametersOption&lt;serde_json::Value&gt;
returnsOption&lt;serde_json::Value&gt;
is_notificationbool

Registry statistics

Fields

FieldTypeDescription
method_countusize
notification_countusize
total_registrationsusize

Fields

FieldTypeDescription
descriptionOption&lt;String&gt;
locationString
nameString

Fields

FieldTypeDescription
authorization_urlString
token_urlString
refresh_urlOption&lt;String&gt;
scopesOption&lt;HashMap&lt;String, String&gt;&gt;
pkce_requiredOption&lt;bool&gt;

Fields

FieldTypeDescription
token_urlString
refresh_urlOption&lt;String&gt;
scopesOption&lt;HashMap&lt;String, String&gt;&gt;

Fields

FieldTypeDescription
device_authorization_urlString
token_urlString
scopesOption&lt;HashMap&lt;String, String&gt;&gt;

Fields

FieldTypeDescription
descriptionOption&lt;String&gt;
schemeString
bearer_formatOption&lt;String&gt;

Fields

FieldTypeDescription
descriptionOption&lt;String&gt;

Fields

FieldTypeDescription
authorization_codeOption&lt;AuthorizationCodeOAuthFlow&gt;
client_credentialsOption&lt;ClientCredentialsOAuthFlow&gt;
device_codeOption&lt;DeviceCodeOAuthFlow&gt;

Fields

FieldTypeDescription
descriptionOption&lt;String&gt;
flowsOAuthFlows
oauth2_metadata_urlOption&lt;String&gt;

Fields

FieldTypeDescription
descriptionOption&lt;String&gt;
open_id_connect_urlString

Security requirement: map of scheme name -> required scopes.

Fields

FieldTypeDescription
schemesHashMap&lt;String, Vec&lt;String&gt;&gt;

Artifact: Agent output (v1.0 shape)

Fields

FieldTypeDescription
artifact_idString
nameOption&lt;String&gt;
descriptionOption&lt;String&gt;
partsVec&lt;Part&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;
extensionsOption&lt;Vec&lt;String&gt;&gt;

Methods

fn new(parts: Vec<Part>) -> Self

Create an artifact with a generated ID.

fn text<impl Into<String>>(text: impl Into) -> Self

Create a simple text artifact.

fn data(value: Value) -> Self

Create a data artifact.

fn with_name<impl Into<String>>(self, name: impl Into) -> Self

Builder: set name.

fn with_description<impl Into<String>>(self, description: impl Into) -> Self

Builder: set description.

fn with_id<impl Into<String>>(self, id: impl Into) -> Self

Builder: set artifact_id explicitly.

fn set_metadata(&mut self, key: String, value: Value)
fn get_text_content(&self) -> Option<&str>

Extract text from the first text part (convenience).

fn get_data_content(&self) -> Option<&Value>

Extract data from the first data part (convenience).

Authentication information for push notification delivery.

Fields

FieldTypeDescription
schemeString
credentialsString

Message: Core A2A communication object (v1.0)

Fields

FieldTypeDescription
roleMessageRole
partsVec&lt;Part&gt;
message_idString
task_idOption&lt;String&gt;
context_idOption&lt;String&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;
extensionsOption&lt;Vec&lt;String&gt;&gt;
reference_task_idsOption&lt;Vec&lt;String&gt;&gt;

Methods

fn new(role: MessageRole, parts: Vec<Part>, task_id: String) -> Self
fn with_id(message_id: String, role: MessageRole, parts: Vec<Part>) -> Self
fn text<impl Into<String>>(role: MessageRole, text: impl Into, task_id: String) -> Self
fn status<impl Into<String>>(text: impl Into, task_id: String) -> Self
fn error<impl Into<String>>(text: impl Into, task_id: String) -> Self
fn add_part(&mut self, part: Part)
fn set_metadata(&mut self, key: String, value: Value)
fn with_context(self, context_id: String) -> Self
fn add_extension(&mut self, extension: String)
fn get_text_content(&self) -> String
fn is_text_only(&self) -> bool
fn get_data_parts(&self) -> Vec<&Part>

Part: Flat multi-modal content container (v1.0)

A Part carries exactly one of: text, raw (base64), url, or structured data. Additional fields (filename, media_type, metadata) annotate the content.

Fields

FieldTypeDescription
textOption&lt;String&gt;
rawOption&lt;String&gt;
urlOption&lt;String&gt;
dataOption&lt;serde_json::Value&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;
filenameOption&lt;String&gt;
media_typeOption&lt;String&gt;

Methods

fn text<impl Into<String>>(text: impl Into) -> Self

Text-only part.

fn data(value: Value) -> Self

Structured data part.

fn url<impl Into<String>>(uri: impl Into) -> Self

URL reference part.

fn raw<impl Into<String>>(base64: impl Into) -> Self

Base64-encoded raw bytes part.

fn url_with_media<impl Into<String>, impl Into<String>>(uri: impl Into, media_type: impl Into) -> Self

URL part with media type annotation.

fn is_text(&self) -> bool

Check which content variant is populated.

fn is_data(&self) -> bool
fn is_url(&self) -> bool
fn is_raw(&self) -> bool
fn get_text(&self) -> Option<&str>

Extract text content (if present).

Task: Core A2A work unit (v1.0)

Fields

FieldTypeDescription
idString
context_idString
statusTaskStatus
historyOption&lt;Vec&lt;Message&gt;&gt;
artifactsOption&lt;Vec&lt;Artifact&gt;&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;

Methods

fn new(context_id: String) -> Self
fn with_id(id: String, context_id: String) -> Self
fn update_status(&mut self, state: TaskState)
fn update_status_with_message(&mut self, state: TaskState, message: Message)
fn add_artifact(&mut self, artifact: Artifact)
fn add_to_history(&mut self, message: Message)
fn set_metadata(&mut self, key: String, value: Value)
fn is_terminal(&self) -> bool
fn is_active(&self) -> bool

Per-task push notification configuration (v1.0).

Fields

FieldTypeDescription
tenantOption&lt;String&gt;
idString
task_idString
urlString
tokenOption&lt;String&gt;
authenticationOption&lt;AuthenticationInfo&gt;

Methods

fn new<impl Into<String>, impl Into<String>, impl Into<String>>(id: impl Into, task_id: impl Into, url: impl Into) -> Self
fn with_tenant<impl Into<String>>(self, tenant: impl Into) -> Self
fn with_token<impl Into<String>>(self, token: impl Into) -> Self
fn with_authentication(self, auth: AuthenticationInfo) -> Self

Task Status: Current state with optional message.

Fields

FieldTypeDescription
stateTaskState
messageOption&lt;Message&gt;
timestampOption&lt;String&gt;

Methods

fn new(state: TaskState) -> Self
fn update_timestamp(&mut self)

Params for GetExtendedAgentCard (was agent/card/getAuthenticatedExtended).

Fields

FieldTypeDescription
auth_tokenOption&lt;String&gt;
scopeOption&lt;Vec&lt;String&gt;&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;

Result for GetExtendedAgentCard.

Fields

FieldTypeDescription
agent_cardcrate::AgentCard
discovery_metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;
timestampOption&lt;String&gt;

Default discovery implementation.

Methods

fn new(agent_card: AgentCard) -> Self
fn with_authentication_required(self, required: bool) -> Self

Request params for CancelTask (was tasks/cancel).

Fields

FieldTypeDescription
idString
tenantOption&lt;String&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;

Methods

fn from_json(params: Value) -> A2AResult<Self>
fn validate(&self) -> A2AResult<()>

Fields

FieldTypeDescription
configTaskPushNotificationConfig

Fields

FieldTypeDescription
idString
task_idString

Fields

FieldTypeDescription
idString
task_idString

Request params for GetTask (was tasks/get).

Fields

FieldTypeDescription
idString
tenantOption&lt;String&gt;
history_lengthOption&lt;u32&gt;

Methods

fn from_json(params: Value) -> A2AResult<Self>
fn validate(&self) -> A2AResult<()>

Fields

FieldTypeDescription
task_idString

Request params for ListTasks (was tasks/list).

Fields

FieldTypeDescription
tenantOption&lt;String&gt;
context_idOption&lt;String&gt;
statusOption&lt;String&gt;
page_sizeOption&lt;u32&gt;
page_tokenOption&lt;String&gt;
history_lengthOption&lt;u32&gt;
status_timestamp_afterOption&lt;String&gt;
include_artifactsbool

Methods

fn from_json(params: Value) -> A2AResult<Self>
fn validate(&self) -> A2AResult<()>

Response for ListTasks.

Fields

FieldTypeDescription
tasksVec&lt;Task&gt;
next_page_tokenOption&lt;String&gt;
page_sizeOption&lt;u32&gt;
total_sizeOption&lt;u32&gt;

Optional configuration for SendMessage.

Fields

FieldTypeDescription
accepted_output_modesOption&lt;Vec&lt;String&gt;&gt;
task_push_notification_configOption&lt;TaskPushNotificationConfig&gt;
history_lengthOption&lt;u32&gt;
return_immediatelybool

Request params for SendMessage (was message/send).

Fields

FieldTypeDescription
messageMessage
tenantOption&lt;String&gt;
configurationOption&lt;SendMessageConfiguration&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;

Methods

fn from_json(params: Value) -> A2AResult<Self>
fn validate(&self) -> A2AResult<()>

Request params for SubscribeToTask (reconnect to existing task SSE).

Fields

FieldTypeDescription
idString
tenantOption&lt;String&gt;

Context Information for Conversation Management

Represents a conversation context that contains multiple tasks following the A2A protocol specification.

Fields

FieldTypeDescription
context_idStringUnique context identifier (persistent across tasks)
created_atStringWhen the conversation started
last_activeStringLast interaction time
task_countu32Number of tasks in this context

Methods

fn new(context_id: String) -> Self

Create a new conversation context

fn update_activity(&mut self)

Update last active timestamp and increment task count

In-Memory Task Storage Implementation

Provides a simple in-memory task storage for development and testing. In production, this would be replaced with persistent storage.

Enhanced A2A Protocol Support: Now includes separate context tracking for proper conversation management with 1:N context:task relationship.

Methods

fn new() -> Self

Create a new in-memory task storage

fn task_count(&self) -> usize

Get the number of stored tasks (for testing)

fn context_count(&self) -> usize

Get the number of stored contexts (for testing)

fn clear(&self)

Clear all tasks and contexts (for testing)

A2A Protocol Error

Variants

VariantDescription
MethodNotFound { ... }
InvalidParams { ... }
AgentUnavailable { ... }
CapabilityValidationFailed { ... }
MethodExecutionFailed { ... }
RegistryError { ... }
ProtocolValidationError { ... }
JsonRpcError(anyhow::Error)
SerializationError(serde_json::Error)
Internal { ... }
TaskNotFound { ... }
TaskNotCancelable { ... }
PushNotificationNotSupported
UnsupportedOperation { ... }
ContentTypeNotSupported { ... }
InvalidAgentResponse { ... }
VersionNotSupported { ... }

Methods

fn to_jsonrpc_error(&self) -> JsonRpcError
fn method_not_found<impl Into<String>>(method: impl Into) -> Self
fn invalid_params<impl Into<String>, impl Into<String>>(method: impl Into, details: impl Into) -> Self
fn agent_unavailable<impl Into<String>, impl Into<String>>(agent_id: impl Into, reason: impl Into) -> Self
fn capability_validation_failed<impl Into<String>>(details: impl Into) -> Self
fn method_execution_failed<impl Into<String>, impl Into<String>>(method: impl Into, details: impl Into) -> Self
fn registry_error<impl Into<String>>(details: impl Into) -> Self
fn protocol_validation_error<impl Into<String>>(details: impl Into) -> Self
fn internal<impl Into<String>>(details: impl Into) -> Self
fn task_not_found<impl Into<String>>(task_id: impl Into) -> Self
fn task_not_cancelable<impl Into<String>>(task_id: impl Into) -> Self
fn unsupported_operation<impl Into<String>>(details: impl Into) -> Self
fn version_not_supported<impl Into<String>>(version: impl Into) -> Self

Security scheme union (v1.0).

Variants

VariantDescription
ApiKey(ApiKeySecurityScheme)
Http(HttpAuthSecurityScheme)
OAuth2(OAuth2SecurityScheme)
OpenIdConnect(OpenIdConnectSecurityScheme)
MutualTls(MutualTlsSecurityScheme)

Message Role (v1.0 — SCREAMING_SNAKE serialization)

Variants

VariantDescription
Unspecified
User
Agent

Task State: A2A v1.0 SCREAMING_SNAKE enum.

Variants

VariantDescription
Unspecified
Submitted
Working
InputRequired
Completed
Failed
Canceled
Rejected
AuthRequired

Methods

fn is_terminal(&self) -> bool

Returns true for terminal states: Completed, Failed, Canceled, Rejected.

fn is_active(&self) -> bool

Returns true for active states: Submitted, Working, InputRequired.

fn as_str(&self) -> &''static str

Lowercase string for logging/display (not wire format).

Response for SendMessage — either a Task or a direct Message.

Serialized as externally-tagged {"task": {...}} or {"message": {...}} matching the protobuf oneof JSON mapping required by A2A v1.0.

Variants

VariantDescription
Task(Task)
Message(Message)