ZEROlobby
22/22 strict⌘Kvisitor
skip to main
ADR-032
skin
——:——:——zcovenant · audit
agent-stream· @zero/agent-stream · 17 events · 1 reducer · 8 primitives

an agent run renders itself through the brand

AG-UI is the third leg of MCP / A2A / AG-UI — a 17-event SSE stream that flows from an agent backend to a UI. @zero/agent-streamships a pure reducer that folds the stream into a typed AgentSession; the brand's existing primitives render every part of the session without a generic chat shell. the run below was reduced at build time from a frozen fixture · 28 events · 4 steps · 4 tool calls · 1 approval.

00 · livePOST /api/agent-stream · AG-UI 17-event SSE · ai-sdk + openai

spawn the agent now · the same primitives, on a real stream

spawn · live· /api/agent-stream · AG-UI 17 events · 0 steps · 0 tool callsidle
01 · protocolAG-UI · 17 event kinds · ADR-032

every event is a discriminated union member

plate · A · AG-UI event vocabulary · @zero/agent-stream/events16 kinds
metric
agent-stream
unit
events
window
static · fixture
agg
count
source
packages/agent-stream/src/events.ts
fresh
last build
groupeventreducer effect
run lifecyclerun.started · run.finished · run.cancelledset runId + status
message lifecyclemessage.start · message.delta · message.endappend + concat into messages[] with streaming flag
tool lifecycletool.start · tool.resultappend + resolve into toolCalls[]
state patchstate.snapshot · state.deltaRFC 6902 patch into state
step lifecyclestep.start · step.delta · step.endappend + status-progress into steps[]
approval (ADR-029 · confirm)approval.request · approval.resolveappend + resolve into approvals[]
terminalerrorset status='error'
why a custom reducer instead of the SDK
the published AG-UI SDK pulls 60+ kB of transitive deps for ~120 lines of switch-case routing. ZERO ships its own pure reducer · 224 lines · 14 vitest cases · zero runtime deps. if AG-UI changes, one file moves.
02 · plan surfaceprimitive a03 · the agent declares what it will do

the run as a numbered, monotonic plan

plate · B · PlanSurface · driven by SESSION.steps4 steps
metric
agent-stream
unit
events
window
static · fixture
agg
count
source
SESSION.steps
fresh
last build
the agent's plan · verb · status · signed hash
  1. 01observeobserve · book + funding skewcomplete
  2. 02decidedecide · reduce 0.7x → 0.4xcomplete
  3. 03eventevent · stop replaced atomicallycomplete
  4. 04refuserefuse · drawdown gate on doge-perprefused
03 · tool callsprimitive a02 · same shape on the way out, same shape on the way back

every tool call is a signed artifact

plate · C · ToolCallCard · driven by SESSION.toolCalls4 calls
metric
agent-stream
unit
events
window
static · fixture
agg
count
source
SESSION.toolCalls
fresh
last build
completehl.book· hyperliquid
{
  "pair": "sol-perp",
  "depth": 5
}
{
  "mid": 184.21,
  "ask1": 184.22,
  "bid1": 184.2
}
◆ tc0aa
completerisk.budget· hyperliquid
{
  "account": "paper-0"
}
{
  "remainingPct": 0.83
}
◆ tc1aa
completehl.cancelReplace· hyperliquid
{
  "oid": "o-9412",
  "newStop": 188.06
}
{
  "rotatedOid": "o-9418"
}
◆ tc2aa
errorrisk.gate· hyperliquid
{
  "pair": "doge-perp"
}
refuse · funding skew above ceiling
◆ tc3aa
04 · approval gateprimitive a04 · decision-node 'confirm' (ADR-029)

every irreversible action pauses for an operator

plate · D · ApprovalGate · driven by SESSION.approvals[0]approve
metric
agent-stream
unit
events
window
static · fixture
agg
count
source
SESSION.approvals
fresh
last build
dry-run the rebalance · book + funding skew · zero settled side-effects
05 · async tasksprimitive a05 · long-running surfaces · five canonical states

durable workflows · queued through complete

plate · E · AsyncTask · five states, one shapecanonical ladder
metric
agent-stream
unit
events
window
static · fixture
agg
count
source
demo · ladder of states
fresh
last build
reconcile · positionsqueued
◆ at0001
next in queue
replay · 24h taperunning
eta · 34s◆ at0002
62% · streaming
settle · paper batchsuspended
eta · ◆ at0003
awaiting approval gate
train · classifier-v3complete
◆ at0004
signed · ready for promotion
export · journal · csvfailed
◆ at0005
schema drift · refuse
06 · evidencereasoning · streaming cursor · evidence trail · confidence · cost · safety

the agent shows its work

plate · F · ReasoningReveal · the agent's hidden plan, on demandprimitive a08
generated@zero/agent
three coins surveyed · two passed gates · one refused · click to reveal trace
model · gpt-5.1 · journaled · replayable
model · gpt-5.1 · 2026-04
inputs · book(sol-perp) · risk(remaining 0.83) · funding(doge-perp +0.046)
plan
  observe · book + funding skew read across 6 paper coins
  decide  · sol-perp short reduce 0.7x → 0.4x · risk delta -0.012
  event   · stop replaced atomically · oid rotated · cancel-replace single tx
  refuse  · doge-perp drawdown gate · funding skew exceeds 0.04 ceiling
output · 1 reduce, 1 cancel-replace, 1 refuse · all signed · 0 unsigned
plate · G · StreamingCursor · message in flightprimitive a01
generated@zero/agent

sol-perp reduced. doge-perp refused. journal signed.

plate · H · EvidenceTrail · provenance for every claimprimitive a19
    evidence · five journal links5 links
plate · I · confidence · cost · safety · per-step posturea14 · a13 · a17
metric
agent-stream
unit
events
window
static · fixture
agg
count
source
per-step posture · synthetic
fresh
last build
92%confidence · plan
three signals agreegenerated
cost$0.0180$0.05
in 1.8kout 612
safety · this runcleared

all gates passed · 3/3 risk · 1/1 liquidity · 0 drift

◆ ss0001
plate · J · TickStream · the journal in motionprimitive a18
metric
agent-stream
unit
events
window
static · fixture
agg
count
source
SESSION.toolCalls → ticks
fresh
last build
hyperliquid · last 8 ticks8
  1. sol-perp184.21000.3124
  2. btc-perp67418.0000116.0018
  3. eth-perp3402.000016.0031
  4. arb-perp0.7800·0.0012
  5. sui-perp4.21000.038
  6. btc-perp67212.0000206.0022
  7. doge-perp0.1420·0.000
  8. eth-perp3415.000013.0019
07 · receiptthe run reduced to one signed artifact · replays bit-exact

every run leaves the same shape

trade receipt◆ run001a
run
run-001
thread
th-014
events
28
steps
3/4 · pass
tools
3/4 · ok
approvals
1/1 · approved
refused
risk.gate · funding skew above ceiling
final
finished
signed
◆ run001a
this entire page is replayable
FIXTURE is frozen. applyEvents(INITIAL_SESSION, FIXTURE)is pure. SSR runs the reducer once at build time and the resulting AgentSession drives every primitive on this page · PlanSurface · ToolCallCard · ApprovalGate · AsyncTask · ReasoningReveal · StreamingCursor · EvidenceTrail · ConfidenceArc · CostMeter · SafetyShield · TickStream · Receipt. switching to a real SSE source means swapping FIXTURE for useAgentStream(url) · the renders never change shape.
◆ run001a replay-safe