spakky-a2a¶
spakky-a2a는@Agent를 A2A AgentCard와 task transport로 노출하고, 원격 A2A teammate를spakky-agentdelegation stream으로 합류시키는 어댑터입니다.
서버 경로는 공식 a2a-sdk request handler와 task store를 사용하며, 실행은 IAgentRunnerFactory가 여는 runner의 AgentEvent stream을 A2A task/message/artifact update로 투영합니다. @A2ACompatible @Agent는 registry에 등록되고 ASGI host Pod가 있으면 JSON-RPC/REST endpoint가 자동 mount됩니다. spakky-grpc의 GrpcServerSpec가 있으면 gRPC handler도 선언형으로 등록됩니다.
Model selection data part¶
A2A message data part는 canonical modelSelection container만 허용하며, 내부 object는
camelCase modelRef 하나만 가집니다.
Legacy model_selection, 한 message의 여러 data part에 중복된 selector,
blank/non-string ref, model_ref, legacy provider/profile/raw model/selection metadata
field는 A2ARunResolutionError입니다. Well-formed unknown ref는 shape parser exception이
아니며 LlmAgentModel의 llm_model_selection_invalid terminal error가 A2A failed task로
표면화됩니다. Catalog 등록과 default 선택은
LLM 모델 라우팅을 확인하세요.
Multimodal inbound¶
A2A executor는 inbound message의 text를 RunAgentInput.instruction으로 사용하고 raw/URL
parts를 MIME family에 따라 ImagePart, AudioPart, VideoPart, DocumentPart attachment로
매핑합니다. Raw bytes와 URL은 provider I/O 전에 core safety contract를 통과하고 document
filename은 있을 때 보존됩니다. Data parts는 attachment로 해석하지 않습니다.
일반 run은 nonblank text가 필요하고 approval-only resume만 "resume" marker를 사용합니다.
Default aggregate bound는 media 16개와 inline bytes 20 MiB입니다. Unknown content kind,
empty bytes, missing/unsupported MIME, local URI와 bound 초과는 A2ARunResolutionError입니다.
Attachment provenance는 A2A message ID에 결속되며 model selection은 별도 data part의
modelSelection.modelRef exact shape를 유지합니다.
Inbound metadata는 얕게 합쳐지고 top-level mcp는 같은 metadata key를 씁니다. 같은
data part에서는 top-level mcp가 metadata.mcp를 덮어쓰고 여러 part에서는 뒤 값이
앞 값을 덮어쓰므로 두 입력 경로를 혼용하지 않습니다. Remote delegation은 text와
working/completed/failed 상태 중심의 축약 mapping이며 모든 remote part/state를 1:1로
보존하지 않습니다.
Local iterative run의 model-N/tool-N step은 ordered working status와 result artifact로
이어집니다. Model step의 provider DONE은 task terminal이 아니며, executor가 전체
runner stream을 drain한 뒤 A2A complete/failed를 한 번만 reconcile합니다.
Candidate-only tool call은 core가 missing START/END만 합성해 working metadata로 투영합니다.
Signal Progress는 signal_progress artifact가 되고 unsupported signal yield는
agent_signal_projection_unsupported failed task입니다. In-run canonical cancel도
cancelled failed task이며 별도 A2A cancel operation의 canceled state와는 다른 경로입니다.
Structured final은 JSON-safe output data part와 declared type 이름의 artifact로 투영한 뒤
task를 complete합니다. output_type=None이면 이 final artifact를 추가하지 않습니다.
Structured-output terminal error는 artifact 없이 error data를 가진 failed task입니다.
A2A data part는 현재 core AgentContext inbound가 아닙니다. Typed dynamic context는 exposed
Agent constructor의 IAgentContextProvider로 공급합니다.
Approval resume data part는 현재 approval_id와 decision만 core signal로 옮깁니다.
modified_payload는 전달하지 않으므로 argument-bearing MODIFY는 A2A ingress에서
지원하지 않습니다. Core runner의 MODIFY 기능이 A2A wire에서도 자동 제공된다고 가정하면
안 됩니다.
Public API¶
A2A (Agent2Agent) protocol server plugin for the Spakky framework.
Exposes a spakky @Agent as an A2A protocol server: an AgentCard is derived
from the agent's spec, tools, and teammates, and JSON-RPC/HTTP plus SSE routes
are mounted from the official a2a-sdk. Marker, config, and plugin identifier
are re-exported; transport types live under a2a-sdk.
SPAKKY_A2A_CONFIG_ENV_PREFIX = 'SPAKKY_A2A_'
module-attribute
¶
Environment prefix for A2A plugin settings.
A2AAgentServer = A2ACompatible
module-attribute
¶
Deprecated alias for :class:A2ACompatible.
PLUGIN_NAME = Plugin(name='spakky-a2a')
module-attribute
¶
Plugin identifier for the A2A integration.
A2AConfig()
¶
Bases: BaseSettings
Configuration for the A2A protocol server integration.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/config.py
default_base_url = DEFAULT_A2A_BASE_URL
class-attribute
instance-attribute
¶
Public host URL combined with the mount path when a marker omits base_url.
default_version = DEFAULT_A2A_VERSION
class-attribute
instance-attribute
¶
Semantic version advertised on a derived AgentCard.
default_mount_path_prefix = DEFAULT_A2A_MOUNT_PATH_PREFIX
class-attribute
instance-attribute
¶
URL prefix under which discovered A2A agents are mounted.
A2ARemoteAgentClient(*, httpx_client=None, config=None)
¶
Small wrapper around the official a2a-sdk client and types.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
resolve_card(card_url)
async
¶
Fetch a remote AgentCard with the SDK resolver.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
send_message(card_url, message)
async
¶
Send a message and collect the SDK response stream.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
stream_message(card_url, message)
async
¶
Send a message and yield remote task/message updates as they arrive.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
get_task(card_url, task_id)
async
¶
Fetch a remote A2A task by id using the SDK client.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
RemoteA2AMessage(text, task_id=None, context_id=None, message_id=(lambda: f'message-{uuid4()}')())
dataclass
¶
Message envelope sent to a remote A2A teammate.
A2AAgentDelegate(client=A2ARemoteAgentClient(), mapper=A2AStreamEventMapper())
dataclass
¶
Bases: IAgentDelegate
Delegate remote teammate calls through the official A2A client.
delegate(packet)
async
¶
Execute a remote delegation packet and yield its terminal result.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/delegation.py
delegate_tool_result(packet)
async
¶
Call a remote A2A teammate and return model result plus child events.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/delegation.py
A2AStreamEventMapper
¶
Map remote A2A SDK stream responses into neutral child events.
map(response, packet)
¶
Project one SDK stream response onto neutral delegated events.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/delegation.py
A2AEndpointConflictError
¶
A2ARunResolutionError(field)
¶
Bases: AbstractSpakkyA2AError
Raised when an inbound A2A request carries invalid run configuration.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
A2ACompatible(base_url=None, version=None, mount_path=None, rest_mount_path=None, rest_base_url=None, grpc_enabled=False, grpc_base_url=None)
dataclass
¶
Bases: Tag
Marks an @Agent class to be served through an A2A protocol endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
base_url |
str | None
|
Public transport endpoint advertised on the derived AgentCard. |
version |
str | None
|
Semantic version advertised on the derived AgentCard. |
mount_path |
str | None
|
Starlette/FastAPI mount path for automatic ASGI exposure. |
base_url = None
class-attribute
instance-attribute
¶
Public endpoint advertised on the derived AgentCard interface.
version = None
class-attribute
instance-attribute
¶
Semantic version advertised on the derived AgentCard.
mount_path = None
class-attribute
instance-attribute
¶
ASGI host mount path. None uses A2AConfig.default_mount_path_prefix.
rest_mount_path = None
class-attribute
instance-attribute
¶
Optional ASGI mount path for the HTTP+JSON REST transport.
rest_base_url = None
class-attribute
instance-attribute
¶
Public REST transport endpoint. None derives from default_base_url + path.
grpc_enabled = False
class-attribute
instance-attribute
¶
Whether to register the official A2A gRPC handler when spakky-grpc is active.
grpc_base_url = None
class-attribute
instance-attribute
¶
Public gRPC transport endpoint advertised by the gRPC handler.
설정¶
A2A plugin configuration.
SPAKKY_A2A_CONFIG_ENV_PREFIX = 'SPAKKY_A2A_'
module-attribute
¶
Environment prefix for A2A plugin settings.
DEFAULT_A2A_BASE_URL = 'http://localhost:8000'
module-attribute
¶
Fallback public host URL used to derive AgentCard transport endpoints.
DEFAULT_A2A_VERSION = '1.0.0'
module-attribute
¶
Fallback semantic version advertised on a derived AgentCard.
DEFAULT_A2A_MOUNT_PATH_PREFIX = '/a2a'
module-attribute
¶
Default Starlette/FastAPI mount prefix for discovered A2A agents.
A2AConfig()
¶
Bases: BaseSettings
Configuration for the A2A protocol server integration.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/config.py
default_base_url = DEFAULT_A2A_BASE_URL
class-attribute
instance-attribute
¶
Public host URL combined with the mount path when a marker omits base_url.
default_version = DEFAULT_A2A_VERSION
class-attribute
instance-attribute
¶
Semantic version advertised on a derived AgentCard.
default_mount_path_prefix = DEFAULT_A2A_MOUNT_PATH_PREFIX
class-attribute
instance-attribute
¶
URL prefix under which discovered A2A agents are mounted.
AgentCard¶
AgentCard derivation from an @Agent declaration.
Maps a spakky @Agent spec, its discovered tool catalog, and its declared
teammates onto an a2a-sdk AgentCard. The a2a-sdk 1.x AgentCard is a
protobuf message (a2a_pb2) whose transport endpoint is expressed as an
AgentInterface entry rather than a flat url field, so the base URL is
advertised through supported_interfaces.
JSON_CONTENT_TYPE = 'application/json'
module-attribute
¶
Tool skills advertise JSON-shaped input and output payloads.
TEXT_CONTENT_TYPE = 'text/plain'
module-attribute
¶
The card's default conversational input and output content type.
TEAMMATE_DELEGATION_TAG = 'delegation'
module-attribute
¶
Tag attached to a skill derived from a declared teammate.
AgentCardFactory
¶
Builds an a2a-sdk AgentCard from an @Agent Pod declaration.
build(agent, base_url, version, protocol=TransportProtocol.JSONRPC)
¶
Derive an AgentCard from an @Agent spec, tools, and teammates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
The @Agent Pod metadata carrying spec and tool catalog. |
required |
base_url
|
str
|
Transport endpoint advertised on the card interface. |
required |
version
|
str
|
Semantic version advertised on the card. |
required |
protocol
|
TransportProtocol
|
A2A transport protocol advertised for |
JSONRPC
|
Returns:
| Type | Description |
|---|---|
AgentCard
|
A protobuf |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/card/derivation.py
서버 등록¶
@A2ACompatible marker for exposing an @Agent over the A2A protocol.
Unlike @GrpcController (which subclasses Controller and registers its own
Pod), this marker subclasses :class:~spakky.core.pod.annotations.tag.Tag: the
@Agent decorator already registers the Pod, so this tag only records the A2A
transport metadata and stacks above @Agent on the same class.
A2ACompatible(base_url=None, version=None, mount_path=None, rest_mount_path=None, rest_base_url=None, grpc_enabled=False, grpc_base_url=None)
dataclass
¶
Bases: Tag
Marks an @Agent class to be served through an A2A protocol endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
base_url |
str | None
|
Public transport endpoint advertised on the derived AgentCard. |
version |
str | None
|
Semantic version advertised on the derived AgentCard. |
mount_path |
str | None
|
Starlette/FastAPI mount path for automatic ASGI exposure. |
base_url = None
class-attribute
instance-attribute
¶
Public endpoint advertised on the derived AgentCard interface.
version = None
class-attribute
instance-attribute
¶
Semantic version advertised on the derived AgentCard.
mount_path = None
class-attribute
instance-attribute
¶
ASGI host mount path. None uses A2AConfig.default_mount_path_prefix.
rest_mount_path = None
class-attribute
instance-attribute
¶
Optional ASGI mount path for the HTTP+JSON REST transport.
rest_base_url = None
class-attribute
instance-attribute
¶
Public REST transport endpoint. None derives from default_base_url + path.
grpc_enabled = False
class-attribute
instance-attribute
¶
Whether to register the official A2A gRPC handler when spakky-grpc is active.
grpc_base_url = None
class-attribute
instance-attribute
¶
Public gRPC transport endpoint advertised by the gRPC handler.
Registry of @Agent instances exposed as A2A servers.
A2AAgentServerEntry(agent_name, instance, agent_type, metadata)
dataclass
¶
A discovered @Agent instance paired with its A2A transport metadata.
A2AAgentRegistry()
¶
Holds the @Agent instances discovered as A2A servers, keyed by name.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/registry.py
register(instance, agent_type, metadata)
¶
Register an @Agent instance under its resolved agent name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
object
|
The @Agent Pod instance to serve. |
required |
agent_type
|
type[object]
|
The original @Agent type, unwrapped from AOP proxies. |
required |
metadata
|
A2ACompatible
|
The A2A transport metadata declared on the agent class. |
required |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/registry.py
get(agent_name)
¶
Return the registered entry for an agent name.
Raises:
| Type | Description |
|---|---|
A2AAgentServerNotRegisteredError
|
No entry exists for the name. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/registry.py
list_entries()
¶
Return registered A2A agent entries in stable name order.
Assembly of a mountable A2A ASGI application for one @Agent instance.
The a2a-sdk 1.x server is assembled from route factories rather than a single
application class: the agent-card route plus the JSON-RPC routes (with v0.3
compatibility enabling the message/send / tasks/get method names) are
mounted on a Starlette app the host application can further mount.
A2AAgentServerSpec
¶
Bases: IContainerAware
Container-aware factory that builds A2A apps for registered agents.
build_app_for(agent_name)
¶
Build a mountable A2A app for a registered agent name.
Resolves the registry entry, then an optional task repository Pod from the container, falling back to an in-memory store when none is registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The registered agent name to serve. |
required |
Returns:
| Type | Description |
|---|---|
Starlette
|
A Starlette application for the named agent. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/builder.py
build_rest_app_for(agent_name)
¶
Build a mountable A2A REST app for a registered agent name.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/builder.py
build_grpc_handler_for(agent_name)
¶
Build an A2A gRPC handler for a registered agent name.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/builder.py
mount_path_for(agent_name)
¶
Return the ASGI mount path for a registered agent.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/builder.py
rest_mount_path_for(agent_name)
¶
Return the optional REST ASGI mount path for a registered agent.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/builder.py
build_a2a_app(agent_instance, *, base_url, version, repository=None, agent_type=None, runner_factory=None)
¶
Assemble a mountable A2A ASGI application for an @Agent instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_instance
|
object
|
The @Agent Pod instance to serve. |
required |
base_url
|
str
|
Transport endpoint advertised on the derived AgentCard. |
required |
version
|
str
|
Semantic version advertised on the derived AgentCard. |
required |
repository
|
IA2ATaskRepository | None
|
Task persistence port; an in-memory store is used when None. |
None
|
agent_type
|
type[object] | None
|
Original @Agent class, supplied when the instance is proxied. |
None
|
Returns:
| Type | Description |
|---|---|
Starlette
|
A Starlette application exposing the agent-card and JSON-RPC routes. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/builder.py
Shared A2A request-handler assembly for all server transports.
build_a2a_request_handler(agent_instance, *, base_url, version, repository=None, agent_type=None, protocol=TransportProtocol.JSONRPC, card=None, runner_factory=None)
¶
Build the official SDK request handler shared by A2A transports.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/server/request_handler.py
Executor¶
a2a-sdk AgentExecutor bound to a spakky @Agent instance.
Drives the framework-owned :class:~spakky.agent.runner.AgentRunner for one A2A
request over the neutral run_events() stream and projects each AgentEvent
onto A2A task events. The A2A task id seeds the agent's durable state_id so a
human-approval pause resumes on the same run when the caller sends the next
message with the same task id and an approval-decision data part.
The runner emits approval/auth interruptions as first-class RunPausedEvent
items, so the A2A projector maps those directly to input-required or
auth-required. This executor only reconciles ordinary RUN_FINISHED
success/failure after the stream drains.
APPROVAL_ID_PART_KEY = 'approval_id'
module-attribute
¶
Inbound data-part key carrying the approval request id to resume.
APPROVAL_DECISION_PART_KEY = 'decision'
module-attribute
¶
Inbound data-part key carrying the chosen approval decision value.
MODEL_SELECTION_PART_KEY = 'modelSelection'
module-attribute
¶
Inbound data-part key carrying a run-scoped model catalog reference.
MODEL_REF_SELECTION_KEY = 'modelRef'
module-attribute
¶
Canonical model-selection key carrying the opaque model catalog reference.
RUN_METADATA_PART_KEY = 'metadata'
module-attribute
¶
Inbound data-part key carrying extra core RunAgentInput metadata.
MCP_PART_KEY = 'mcp'
module-attribute
¶
Inbound data-part key carrying runtime MCP server selectors.
RUN_FAILED_FALLBACK_MESSAGE = 'run failed'
module-attribute
¶
Status message used when a failed run carries no error message.
SpakkyAgentExecutor(agent, projector, runner_factory=None)
¶
Bases: AgentExecutor
Bridges A2A request execution onto the spakky agent event stream.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/executor/adapter.py
Projection of neutral AgentEvent items onto A2A task events.
The runner's run_events() emits the protocol-neutral AgentEvent taxonomy
(ADR-0013 §3); this projector reproduces each event one-to-one as an a2a-sdk task
update. A2A 1.x parts are protobuf messages: text is Part(text=...) and
structured data is Part(data=<google.protobuf.Value>), built from a
JSON-compatible value via ParseDict.
RUN_FINISHED is not applied as a terminal transition here: the executor owns
the single complete/failed terminal update after draining the stream. Neutral
RUN_PAUSED events are different: they are already non-terminal protocol
interrupts, so this projector maps them directly to A2A input-required or
auth-required task states.
CUSTOM_EVENT_METADATA_KEY = 'custom_event'
module-attribute
¶
Message metadata key carrying an application custom event's name.
RunOutcome(error, paused=False)
dataclass
¶
Terminal or interrupt result of one run, reconciled by the executor.
error is None for a successful run and carries the runner's terminal
failure payload otherwise. paused is true after a RUN_PAUSED event
has already applied the non-terminal task transition.
AgentEventProjector
¶
Projects neutral AgentEvent items onto a2a-sdk task-event updates.
project(event, updater)
async
¶
Publish A2A events for one agent event via the task updater.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
AgentEvent
|
The neutral event emitted by the agent runner. |
required |
updater
|
TaskUpdater
|
The a2a-sdk updater bound to the running task. |
required |
Returns:
| Type | Description |
|---|---|
RunOutcome | None
|
The run's terminal outcome for a |
Raises:
| Type | Description |
|---|---|
UnsupportedAgentEventError
|
The event kind has no A2A projection. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/executor/event_mapping.py
Transports¶
HTTP+JSON REST transport bindings for the official A2A routes.
build_a2a_rest_app(agent_instance, *, base_url, version, repository=None, agent_type=None, path_prefix='', runner_factory=None)
¶
Build a mountable A2A HTTP+JSON REST app for one @Agent instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_instance
|
object
|
The @Agent Pod instance to serve. |
required |
base_url
|
str
|
Transport endpoint advertised on the derived AgentCard. |
required |
version
|
str
|
Semantic version advertised on the derived AgentCard. |
required |
repository
|
IA2ATaskRepository | None
|
Task persistence port; an in-memory store is used when None. |
None
|
agent_type
|
type | None
|
Original @Agent class, supplied when the instance is proxied. |
None
|
path_prefix
|
str
|
Optional URL prefix for the REST operation routes. |
''
|
Returns:
| Type | Description |
|---|---|
Starlette
|
A Starlette application exposing AgentCard plus HTTP+JSON A2A routes. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/rest_transport/builder.py
Assembly helpers for the A2A HTTP+JSON REST transport.
build_a2a_rest_app(agent_instance, *, base_url, version, repository=None, agent_type=None, path_prefix='', runner_factory=None)
¶
Build a mountable A2A HTTP+JSON REST app for one @Agent instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_instance
|
object
|
The @Agent Pod instance to serve. |
required |
base_url
|
str
|
Transport endpoint advertised on the derived AgentCard. |
required |
version
|
str
|
Semantic version advertised on the derived AgentCard. |
required |
repository
|
IA2ATaskRepository | None
|
Task persistence port; an in-memory store is used when None. |
None
|
agent_type
|
type | None
|
Original @Agent class, supplied when the instance is proxied. |
None
|
path_prefix
|
str
|
Optional URL prefix for the REST operation routes. |
''
|
Returns:
| Type | Description |
|---|---|
Starlette
|
A Starlette application exposing AgentCard plus HTTP+JSON A2A routes. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/rest_transport/builder.py
gRPC transport bindings for the official A2A service descriptor.
A2A_GRPC_SERVICE = 'lf.a2a.v1.A2AService'
module-attribute
¶
Fully qualified official A2A gRPC service name from the a2a-sdk descriptor.
A2AGrpcHandler(handler)
¶
Bases: GenericRpcHandler
Generic gRPC handler for the official A2A service methods.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/grpc_transport/handler.py
service(handler_call_details)
¶
Return the method handler for an official A2A gRPC path.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/grpc_transport/handler.py
build_a2a_grpc_handler(agent_instance, *, base_url, version, repository=None, agent_type=None, runner_factory=None)
¶
Build a gRPC handler for one @Agent-backed A2A server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_instance
|
object
|
The @Agent Pod instance to serve. |
required |
base_url
|
str
|
Transport endpoint advertised on the derived AgentCard. |
required |
version
|
str
|
Semantic version advertised on the derived AgentCard. |
required |
repository
|
IA2ATaskRepository | None
|
Task persistence port; an in-memory store is used when None. |
None
|
agent_type
|
type | None
|
Original @Agent class, supplied when the instance is proxied. |
None
|
Returns:
| Type | Description |
|---|---|
A2AGrpcHandler
|
A generic gRPC handler exposing the official A2A service methods. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/grpc_transport/builder.py
Assembly helpers for the A2A gRPC transport.
build_a2a_grpc_handler(agent_instance, *, base_url, version, repository=None, agent_type=None, runner_factory=None)
¶
Build a gRPC handler for one @Agent-backed A2A server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_instance
|
object
|
The @Agent Pod instance to serve. |
required |
base_url
|
str
|
Transport endpoint advertised on the derived AgentCard. |
required |
version
|
str
|
Semantic version advertised on the derived AgentCard. |
required |
repository
|
IA2ATaskRepository | None
|
Task persistence port; an in-memory store is used when None. |
None
|
agent_type
|
type | None
|
Original @Agent class, supplied when the instance is proxied. |
None
|
Returns:
| Type | Description |
|---|---|
A2AGrpcHandler
|
A generic gRPC handler exposing the official A2A service methods. |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/grpc_transport/builder.py
Official A2A gRPC service handler backed by the existing A2A executor.
The a2a-sdk ships protobuf descriptors for lf.a2a.v1.A2AService. This
handler binds those official method names to the same DefaultRequestHandler
used by the JSON-RPC transport, so AgentCard derivation, task persistence,
executor adaptation, and neutral agent-event projection remain shared.
A2A_GRPC_SERVICE = 'lf.a2a.v1.A2AService'
module-attribute
¶
Fully qualified official A2A gRPC service name from the a2a-sdk descriptor.
A2AGrpcHandler(handler)
¶
Bases: GenericRpcHandler
Generic gRPC handler for the official A2A service methods.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/grpc_transport/handler.py
service(handler_call_details)
¶
Return the method handler for an official A2A gRPC path.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/grpc_transport/handler.py
Client와 Delegation¶
Official a2a-sdk client wrapper for remote teammate calls.
DEFAULT_AGENT_CARD_PATH = '/.well-known/agent-card.json'
module-attribute
¶
Default A2A well-known AgentCard route.
RemoteA2AMessage(text, task_id=None, context_id=None, message_id=(lambda: f'message-{uuid4()}')())
dataclass
¶
Message envelope sent to a remote A2A teammate.
A2ARemoteAgentClient(*, httpx_client=None, config=None)
¶
Small wrapper around the official a2a-sdk client and types.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
resolve_card(card_url)
async
¶
Fetch a remote AgentCard with the SDK resolver.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
send_message(card_url, message)
async
¶
Send a message and collect the SDK response stream.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
stream_message(card_url, message)
async
¶
Send a message and yield remote task/message updates as they arrive.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
get_task(card_url, task_id)
async
¶
Fetch a remote A2A task by id using the SDK client.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/client.py
A2A-backed teammate delegation for @Agent teammate specs.
A2AStreamEventMapper
¶
Map remote A2A SDK stream responses into neutral child events.
map(response, packet)
¶
Project one SDK stream response onto neutral delegated events.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/delegation.py
A2AAgentDelegate(client=A2ARemoteAgentClient(), mapper=A2AStreamEventMapper())
dataclass
¶
Bases: IAgentDelegate
Delegate remote teammate calls through the official A2A client.
delegate(packet)
async
¶
Execute a remote delegation packet and yield its terminal result.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/delegation.py
delegate_tool_result(packet)
async
¶
Call a remote A2A teammate and return model result plus child events.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/delegation.py
Task Store¶
Plugin-owned persistence port for A2A task state.
The a2a-sdk TaskStore ABC is async and threads a ServerCallContext
through every call. This plugin owns a narrower synchronous repository port so
that adapters (in-memory today, a database-backed implementation later) stay
free of a2a-sdk server types; the async bridge lives in task_store.
In-memory task repository plus the async a2a-sdk TaskStore bridge.
InMemoryA2ATaskRepository()
¶
Bases: IA2ATaskRepository
Dictionary-backed synchronous A2A task repository.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/store/task_store.py
SpakkyA2ATaskStore(repository)
¶
Bases: TaskStore
Async a2a-sdk TaskStore delegating to a synchronous repository.
The a2a-sdk request handler awaits every store call, but the plugin's repository port is synchronous; each async method calls straight through to the in-process repository, which performs no I/O of its own.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/store/task_store.py
Plugin¶
Post-processor registering @A2ACompatible-marked @Agent Pods.
RegisterA2AAgentServersPostProcessor
¶
Bases: IPostProcessor, IContainerAware
Registers Pods carrying both @Agent and @A2ACompatible in the registry.
post_process(pod)
¶
Register pod when it is an @A2ACompatible-marked @Agent.
Pods missing either marker are returned unchanged.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/post_processors/register_agent_servers.py
Post-processor that mounts discovered A2A agents on ASGI host Pods.
MountA2AASGIPostProcessor()
¶
Bases: IPostProcessor, IContainerAware, IApplicationContextAware
Mount registered A2A agent apps on Starlette-compatible host Pods.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/post_processors/mount_asgi.py
post_process(pod)
¶
Mount registered A2A servers when a host or marked agent appears.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/post_processors/mount_asgi.py
Post-processor registering A2A gRPC handlers with spakky-grpc.
GRPC_SERVER_SPEC_MODULE = 'spakky.plugins.grpc.server_spec'
module-attribute
¶
Module path used to identify spakky-grpc's GrpcServerSpec without importing it.
GRPC_SERVER_SPEC_NAME = 'GrpcServerSpec'
module-attribute
¶
Class name used to identify spakky-grpc's GrpcServerSpec without importing it.
RegisterA2AGRPCPostProcessor()
¶
Bases: IPostProcessor, IContainerAware
Register @A2ACompatible gRPC handlers when spakky-grpc is active.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/post_processors/register_grpc.py
post_process(pod)
¶
Register enabled A2A gRPC handlers when a spec or agent appears.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/post_processors/register_grpc.py
Plugin initialization for the A2A protocol server integration.
Registers the plugin configuration, the agent-server registry, the container-aware app-builder spec, and the post-processor that discovers @A2ACompatible-marked @Agent Pods. This function is called automatically during plugin loading.
initialize(app)
¶
Initialize the A2A plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
SpakkyApplication
|
The Spakky application instance. |
required |
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/main.py
에러¶
A2A plugin error hierarchy.
Provides the base error class plus concrete errors raised while deriving an AgentCard, projecting neutral agent events onto A2A task events, and resolving a registered A2A agent server.
AbstractSpakkyA2AError
¶
A2AAgentServerNotRegisteredError(agent_name)
¶
Bases: AbstractSpakkyA2AError
Raised when no A2A agent server is registered for a requested name.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
A2AAgentCardDerivationError(agent_name)
¶
Bases: AbstractSpakkyA2AError
Raised when an AgentCard cannot be derived from an @Agent declaration.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
A2AEndpointConflictError
¶
UnsupportedAgentEventError(kind)
¶
Bases: AbstractSpakkyA2AError
Raised when an AgentEvent kind has no A2A task-event projection.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
UnsupportedFinalOutputError(output_type)
¶
Bases: AbstractSpakkyA2AError
Raised when a final agent output cannot be projected to an A2A part.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
InvalidApprovalDecisionError(decision)
¶
Bases: AbstractSpakkyA2AError
Raised when an inbound approval-decision part carries an unknown decision.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
A2ARunResolutionError(field)
¶
Bases: AbstractSpakkyA2AError
Raised when an inbound A2A request carries invalid run configuration.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
UnsupportedA2AGrpcResultError(result_type)
¶
Bases: AbstractSpakkyA2AError
Raised when a unary A2A gRPC method returns an unsupported result.
Source code in plugins/spakky-a2a/src/spakky/plugins/a2a/error.py
UnsupportedA2AGrpcEventError(event_type)
¶
Bases: AbstractSpakkyA2AError
Raised when a streaming A2A gRPC event cannot be wrapped.