Index
a2a
¶
Agent-to-Agent protocol — Google A2A spec implementation.
Classes¶
A2AClient
¶
Client for calling external A2A-compatible agents.
Discovers agent capabilities via /.well-known/agent.json and sends tasks via /a2a/tasks.
Source code in src/openjarvis/a2a/client.py
Functions¶
discover
¶
discover() -> AgentCard
Fetch the agent card from /.well-known/agent.json.
Source code in src/openjarvis/a2a/client.py
send_task
¶
send_task(input_text: str, **kwargs: Any) -> A2ATask
Send a task to the remote agent and return the result.
Source code in src/openjarvis/a2a/client.py
get_task
¶
get_task(task_id: str) -> A2ATask
Get the status of a previously submitted task.
Source code in src/openjarvis/a2a/client.py
cancel_task
¶
cancel_task(task_id: str) -> A2ATask
Cancel a running task.
Source code in src/openjarvis/a2a/client.py
A2ARequest
dataclass
¶
JSON-RPC 2.0 request for A2A.
A2AResponse
dataclass
¶
JSON-RPC 2.0 response for A2A.
A2ATask
dataclass
¶
A2ATask(task_id: str = (lambda: hex[:16])(), state: TaskState = SUBMITTED, input_text: str = '', output_text: str = '', history: List[Dict[str, str]] = list(), metadata: Dict[str, Any] = dict())
An A2A task with state machine.
AgentCard
dataclass
¶
AgentCard(name: str, description: str = '', url: str = '', version: str = '0.1.0', capabilities: List[str] = list(), skills: List[str] = list(), authentication: Dict[str, Any] = dict())
Agent discovery card served at /.well-known/agent.json.
A2AServer
¶
A2AServer(agent_card: AgentCard, *, handler: Optional[Callable[[str], str]] = None, bus: Optional[EventBus] = None, auth_token: Optional[str] = None)
A2A server that processes incoming tasks via agent execution.
Can be mounted as routes in the FastAPI server.
When auth_token is set, every :meth:handle_request call must present a
matching bearer token or it is rejected before any agent runs. The token
is advertised on the agent card's authentication field. When unset,
the server is unauthenticated — only mount it on a trusted network.
Source code in src/openjarvis/a2a/server.py
Functions¶
authenticate
¶
Constant-time check of a presented bearer token.
Returns True when no auth_token is configured (auth disabled).
Source code in src/openjarvis/a2a/server.py
handle_request
¶
Process a JSON-RPC 2.0 A2A request.
token is the bearer credential extracted by the transport (e.g. the
HTTP Authorization header). It is validated before dispatch when
the server is configured with an auth_token.
Source code in src/openjarvis/a2a/server.py
get_routes
¶
Return route definitions for mounting in a web framework.
Source code in src/openjarvis/a2a/server.py
A2AAgentTool
¶
A2AAgentTool(client: A2AClient, *, name: str = '')
Bases: BaseTool
Wraps an external A2A agent as a BaseTool.
Follows the MCPToolAdapter pattern for external tool integration.