xr_ai_runtime#
Typed in-process runtime for composable XR AI agents.
Exceptions#
Raised when work is submitted to a runtime that is not running. |
Classes#
An object that owns state and exposes ordinary native tools. |
|
Routing and trace context for one published event. |
|
A stable publish/subscribe name paired with its payload model. |
|
Provide typed pub/sub routing between registered agents. |
|
Runtime operations available during a subscription delivery. |
Functions#
|
Register an agent method as a typed topic subscriber. |
Package Contents#
- class xr_ai_runtime.Agent(
- tools: collections.abc.Iterable[xr_ai_tools.Tool[Any, Any] | xr_ai_tools.AsyncTool[Any, Any]] = (),
An object that owns state and exposes ordinary native tools.
- property tools: tuple[xr_ai_tools.Tool[Any, Any] | xr_ai_tools.AsyncTool[Any, Any], Ellipsis]#
Return the existing native tools exposed by this agent.
- class xr_ai_runtime.MessageMetadata#
Routing and trace context for one published event.
- message_id: str#
Unique identifier for this publication.
- correlation_id: str#
Identifier shared by publications in one logical operation.
- participant_id: str | None#
Participant routing key, or
Nonefor a global event.
- source: str#
Runtime-local name of the publisher.
- parent_message_id: str | None#
Identifier of the publication that caused this event, when present.
- timestamp_us: int#
Publication time as Unix microseconds.
- class xr_ai_runtime.Topic#
A stable publish/subscribe name paired with its payload model.
- name: str#
Stable name shared by every publisher and subscriber.
- message_type: type[MessageT]#
Pydantic model used to validate each publication.
- telemetry: Literal['full', 'none'] = 'full'#
Whether Relay records publication and subscriber-delivery scopes.
- validate(message: MessageT | dict[str, Any]) MessageT#
Validate a message before delivery.
- xr_ai_runtime.subscribe(
- topic: Topic[MessageT],
Register an agent method as a typed topic subscriber.
- class xr_ai_runtime.AgentRuntime#
Provide typed pub/sub routing between registered agents.
- property running: bool#
Whether the runtime currently accepts event work.
- register(name: str, agent: AgentT) AgentT#
Register one agent before startup and return the same typed object.
- async start() None#
Start accepting event publications.
- async publish(
- topic: xr_ai_runtime.events.Topic[MessageT],
- message: MessageT | dict[str, Any],
- *,
- participant_id: str | None = None,
- source: str = 'application',
Validate and deliver one event to every topic subscriber.
- async stop() None#
Stop accepting events and cancel in-flight deliveries.
- exception xr_ai_runtime.RuntimeClosedError#
Raised when work is submitted to a runtime that is not running.
- class xr_ai_runtime.RuntimeContext(
- runtime: AgentRuntime,
- agent_name: str,
- metadata: xr_ai_runtime.events.MessageMetadata,
Runtime operations available during a subscription delivery.
- property agent_name: str#
Return this agent’s runtime-local name.
- property metadata: xr_ai_runtime.events.MessageMetadata#
Return metadata for the current subscription delivery.
- async publish(
- topic: xr_ai_runtime.events.Topic[MessageT],
- message: MessageT | dict[str, Any],
- *,
- participant_id: str | None = None,
Publish an event, preserving delivery scope when one exists.