Agent-to-Agent¶
Protocol Types¶
A2AMessage
dataclass
¶
A message in the A2A protocol.
Attributes:
| Name | Type | Description |
|---|---|---|
message_type |
A2AMessageType
|
The type of this message. |
sender |
str
|
Identifier of the sending agent. |
receiver |
str
|
Identifier of the receiving agent. |
payload |
dict[str, Any]
|
The message payload data. |
correlation_id |
str
|
ID linking related messages in a conversation. |
metadata |
dict[str, Any]
|
Additional metadata. |
Source code in src/agenticapi/interface/a2a/protocol.py
A2AMessageType ¶
Bases: StrEnum
Standard A2A protocol message types.
Source code in src/agenticapi/interface/a2a/protocol.py
A2ARequest
dataclass
¶
A request sent to an A2A service.
Attributes:
| Name | Type | Description |
|---|---|---|
capability_name |
str
|
The capability being invoked. |
parameters |
dict[str, Any]
|
Request parameters. |
sender |
str
|
Identifier of the requesting agent. |
correlation_id |
str
|
ID for tracking the conversation. |
timeout_seconds |
float
|
Maximum time to wait for a response. |
Source code in src/agenticapi/interface/a2a/protocol.py
A2AResponse
dataclass
¶
A response from an A2A service.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Whether the request was processed successfully. |
result |
Any
|
The result data. |
error |
str | None
|
Error message if unsuccessful. |
correlation_id |
str
|
ID linking to the original request. |
Source code in src/agenticapi/interface/a2a/protocol.py
Capability¶
Capability
dataclass
¶
A capability offered by an A2A service.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique name identifying this capability. |
description |
str
|
Human-readable description of what this capability does. |
input_schema |
dict[str, Any]
|
JSON-schema-like dict describing expected input. |
output_schema |
dict[str, Any]
|
JSON-schema-like dict describing output format. |
sla_max_latency_ms |
int
|
Maximum expected latency in milliseconds. |
sla_availability |
float
|
Target availability (0.0-1.0). |
Source code in src/agenticapi/interface/a2a/capability.py
CapabilityRegistry ¶
Registry of capabilities offered by a service.
Agents register their capabilities here, and remote agents can discover them via the A2A DISCOVER message.
Example
registry = CapabilityRegistry() registry.register(Capability( name="inventory_lookup", description="Look up current inventory levels", )) caps = registry.list_capabilities()
Source code in src/agenticapi/interface/a2a/capability.py
register ¶
Register a capability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
Capability
|
The capability to register. |
required |
Source code in src/agenticapi/interface/a2a/capability.py
get ¶
Look up a capability by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The capability name. |
required |
Returns:
| Type | Description |
|---|---|
Capability | None
|
The capability if found, None otherwise. |
list_capabilities ¶
List all registered capabilities.
Returns:
| Type | Description |
|---|---|
list[Capability]
|
All registered capabilities. |
has ¶
Check if a capability is registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The capability name. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the capability exists. |
Trust¶
TrustPolicy
dataclass
¶
Policy governing trust between agents.
Attributes:
| Name | Type | Description |
|---|---|---|
initial_trust |
float
|
Trust score for unknown agents (0.0-1.0). |
min_trust_for_read |
float
|
Minimum trust to allow read operations. |
min_trust_for_write |
float
|
Minimum trust to allow write operations. |
decay_per_failure |
float
|
How much trust decreases on failure. |
gain_per_success |
float
|
How much trust increases on success. |
Source code in src/agenticapi/interface/a2a/trust.py
TrustScorer ¶
Tracks and computes trust scores for remote agents.
Trust scores are updated based on interaction outcomes and used to gate what operations remote agents can perform.
Example
scorer = TrustScorer(policy=TrustPolicy()) score = scorer.get_score("agent-123") scorer.record_success("agent-123")
Source code in src/agenticapi/interface/a2a/trust.py
__init__ ¶
Initialize the trust scorer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
TrustPolicy | None
|
The trust policy to apply. Uses defaults if None. |
None
|
Source code in src/agenticapi/interface/a2a/trust.py
get_score ¶
Get the trust score for an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
The agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The trust score (0.0-1.0). Returns initial_trust for unknown agents. |
Source code in src/agenticapi/interface/a2a/trust.py
can_read ¶
Check if an agent is trusted enough for read operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
The agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the agent meets the minimum read trust threshold. |
Source code in src/agenticapi/interface/a2a/trust.py
can_write ¶
Check if an agent is trusted enough for write operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
The agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the agent meets the minimum write trust threshold. |
Source code in src/agenticapi/interface/a2a/trust.py
record_success ¶
Record a successful interaction, increasing trust.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
The agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The updated trust score. |
Source code in src/agenticapi/interface/a2a/trust.py
record_failure ¶
Record a failed interaction, decreasing trust.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
The agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The updated trust score. |