generative-a11y
AG-UI

bindAgent

Connect an AG-UI agent to your application runtime.

Signature and import

Create the binding after the agent is ready, then dispose it when the owning application scope ends.

agent-accessibility.ts
import { bindAgent } from "@generative-a11y/ag-ui";

const binding = bindAgent({
  runtime,
  scopeId: "research-agent",
  agent,
});

// Call when the owning scope ends; the agent and runtime remain yours.
function disposeAgentBinding() {
  binding.dispose();
}

The binding subscribes without running the agent. Keep scopeId stable and unique across mounted agents; disposing the binding leaves both the agent and runtime under your app’s control.

Options

Prop

Type

After the tracking limit is exhausted, the binding suppresses subsequent lifecycle events, including events for known identities. Create a fresh binding at an intentional session boundary to resume observation.

How AgentSubscriber callbacks map to events

AG-UI integration reads public callbacks instead of rendered UI.

AG-UI callback familygenerative-a11y eventNotes
Run start and finishrun lifecycleUses protocol run identity and preserves documented lineage
Subagent start and finishdelegated child run lifecyclePreserves explicit parent run, tool, and message ownership
Step start and finishpartial step lifecycleKeeps stepName as a label and omits stepId
Text message start, content, endresponse lifecycleEach update contains only new text
Tool call start, args, result, endtool lifecycleArguments alone do not mean execution started
Run error or interruptionrun and active descendant terminal eventsEnds active response, tool, child run, and root run state
Interrupt and resumeinteraction requested or resolvedReports when the app needs user input
Run initializedinteraction resolutionMatches known active interrupt IDs

Declared fidelity

AG-UI 0.0.59 provides stable run and subagent IDs. Step callbacks provide stepName but no stable step ID, so step and hierarchy fidelity are partial. Replay and reconnection are partial, retry support is unavailable, and custom events require an explicit host mapping.