Skip to content

API Reference parrot.outputs.a2ui.runtime.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.outputs.a2ui.runtime.models

View source

A2UI Agent Functions runtime — pure-data models and error codes.

Implements spec a2ui-agent-functions (FEAT-469) §3 Module 1: the types every other runtime module (dispatch.py, adapters.py) consumes.

This module is pure protocol data (Pydantic v2 models + a str-enum) and MUST NEVER import parrot.bots, parrot.clients, parrot.tools, or parrot.memory at module level (the G8 one-way import rule, spec §7). A2UICallContext.permission_context is deliberately typed Any rather than importing :class:parrot.auth.permission.PermissionContext — the runtime treats it as an opaque token handed back to the transport-provided executor, never inspecting it itself.

Error codes: :class:A2UIErrorCode mixes two families. INVALID_FUNCTION_CALL, UNALLOWED_PARENT, and UNALLOWED_CHILD are protocol-defined (they match :data:parrot.outputs.a2ui.models._VALIDATION_ERROR_CODES plus the wire's generic-error convention). FORBIDDEN, NOT_FOUND, INTERNAL, and TIMEOUT are parrot extensions — the A2UI v1.0 wire spec reserves no fixed code list for "Generic Error" (any string is legal there), so these are our own conventions layered on top, not part of the official protocol.

Class A2UICallContext

The context a transport builds for a single R->A invocation.

Fields:

Field Type Default Description
agent_id str The id of the agent handling this call.
user_id str | None None The authenticated user id, if any. Integer/UUID ids from an auth backend are coerced to their string form.
session_id str The conversation session id.
surface_id str | None None The surface this call is scoped to, if known.
permission_context Any None Opaque parrot.auth.permission.PermissionContext, passed straight through to ToolManager.execute_tool(). Typed Any on purpose — the runtime never imports or inspects it (G8).
transport Literal['http', 'a2a', 'deeplink'] Which transport built this context.
streaming bool False Whether the call is part of a streaming exchange.

Class A2UIErrorCode

A2UI runtime error codes.

INVALID_FUNCTION_CALL, UNALLOWED_PARENT, and UNALLOWED_CHILD are protocol-facing generic-error codes. FORBIDDEN, NOT_FOUND, INTERNAL, and TIMEOUT are parrot-specific extensions — do not "correct" them against an official A2UI code list, because none exists for generic errors.

Class DispatchResult

The outcome of :meth:A2UIRuntime.dispatch (TASK-2569).

Fields:

Field Type Default Description
messages list[dict[str, Any]] Already-serialized A->R envelopes ({"version": "v1.0", ...}) to return to the renderer.
user_turn str | None None A structured user/system turn to inject into the bot, if the dispatched message was an action.
surface_state SurfaceState | None None The updated :class:SurfaceState, if sendDataModel was honoured for this dispatch.

Class FunctionCallRecord

An agent->renderer callRendererFunction call awaiting correlation.

Fields:

Field Type Default Description
function_call_id str The unique id the renderer must echo back in its rendererFunctionResponse/error.
surface_id str | None None The surface this call targets, if any.
call str The renderer function name being invoked.
catalog_id str | None None The catalog the function belongs to, if not the default.
args dict[str, Any] The arguments passed to the renderer function.
created_at datetime When this record was registered (UTC).
ttl_seconds int 900 Seconds after created_at this record may still be resolved. Defaults to 900s (15 minutes).

Class SurfaceState

The last known dataModel for a surface (spec G3 sendDataModel).

Fields:

Field Type Default Description
surface_id str The surface this state belongs to.
catalog_id str The surface's catalog id.
data_model dict[str, Any] The last full data model reported for this surface.
updated_at datetime When this state was last updated (UTC).

Function error_envelope

Build a schema-valid {"version": "v1.0", "error": {...}} envelope.

Always goes through :class:~parrot.outputs.a2ui.models.ErrorMessage + :func:~parrot.outputs.a2ui.serialization.serialize — this function never hand-writes the version field (spec §7: "el runtime nunca escribe version a mano"; serialization owns it).

error_envelope(code: A2UIErrorCode, message: str, *, function_call_id: str | None = None, surface_id: str | None = None, path: str | None = None) -> dict[str, Any]

Parameter Type Default Description
code A2UIErrorCode The error code. Determines which of the two wire shapes applies ("Validation Failed" vs. "Generic Error").
message str A short, safe description of the error. MUST NOT contain exception text or a traceback — log the real cause with logger.exception instead.
function_call_id str | None None The function invocation this error responds to. Only valid for a Generic Error; mutually exclusive with surface_id.
surface_id str | None None The surface where the error occurred. Required (with path) for a Validation Failed error; for a Generic Error, mutually exclusive with function_call_id.
path str | None None JSON pointer to the field that failed validation. Only valid (and required) for a Validation Failed error.

Returns: dict[str, Any] — A JSON-ready envelope dict with exactly two keys: version and error.

Raises:

  • ValueError — If code/surface_id/function_call_id/path do not form one of the two valid wire shapes. :class:pydantic.ValidationError (raised by :class:~parrot.outputs.a2ui.models.ErrorMessage's own shape validator) is a ValueError subclass, so this is the single source of truth for what counts as a malformed error envelope — this function does not duplicate that check.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally