Skip to content

Part 4 · Event Layer & UI Integration

The only interface between the agent runtime and your UI is the Transport. This part bridges the agent event stream to any UI shape (CLI, web, native mobile, background batch).

Key terms in this Part

  • Transport — push interface (emit / ask_confirmation / ask_user / bailout); the only seam between runtime and your UI · §4.1, G.2
  • AgentEvent — internal event types (text chunk, tool started/completed, LLM call) — debug only, not stable across releases · §4.2, G.6
  • HostEvent — Pydantic-typed lifecycle event (tool / permission / subagent); stable, with schema snapshots · §4.7, G.1
  • agent.events() — async pull iterator on the stable agentao.host surface; use for audit / SIEM / billing · §4.7
  • active_permissions() — JSON-safe snapshot of the effective policy; use for "who can do what" UIs · §4.7, G.5

Coverage

Before you start

Read by task

What you are buildingRecommended pathYou should be able to
Stream agent output into a web or app UI4.14.34.4Choose a Transport shape and push tokens, tool states, and errors to the frontend
Build tool confirmation, approval, or human-in-the-loop flows4.14.55.4Separate UI confirmation, permission rules, and unattended policy
Feed audit, billing, or SIEM pipelines4.76.6Use stable HostEvent data instead of internal AgentEvent details
Look up an event field or debug UI state4.24.7Know which events are for debugging and which APIs are production-safe
Prevent stuck agents or infinite loops4.62.6Design max-iteration, timeout, and fallback behavior

Mental model

Transport is your "UI spokesperson" — the agent interacts with the outside world only through it: emit events, ask for confirmation, ask the user, report bailouts. The stronger your Transport, the steadier your UX.

Start with 4.1 →