Skip to content

feat(agents-server-ui): show per-response token usage in meta row#4502

Open
kevin-dp wants to merge 1 commit into
mainfrom
kevin/agent-token-usage
Open

feat(agents-server-ui): show per-response token usage in meta row#4502
kevin-dp wants to merge 1 commit into
mainfrom
kevin/agent-token-usage

Conversation

@kevin-dp
Copy link
Copy Markdown
Contributor

@kevin-dp kevin-dp commented Jun 4, 2026

Summary

Adds a token-usage label to the agent response meta row, e.g.
Thinking · 12s · 1.2k ↑ 412 ↓ while streaming and
✓ done in 12s · 1.2k ↑ 412 ↓ · 14:18 once settled. Counter updates at
step boundaries — for a single-turn LLM call it lands once at done;
for tool-using runs it jumps as each step completes (the LLM SDK only
emits usage at end-of-step, so we can't tick smoothly between
streamed tokens — the elapsed-time ticker still ticks every second
alongside it).

Plumbing

The runtime already had the token data — pi-adapter.ts:358-359
extracts tokenInput/tokenOutput from the provider's per-step
usage payload — but the bridge silently dropped them before
persistence. This PR closes that gap and surfaces them all the way to
the UI:

  • StepValue gains optional input_tokens / output_tokens columns
    (Zod + TS). Strictly additive: events recorded before this change
    still validate (both fields optional), so no migration is needed.
  • outbound-bridge.ts:onStepEnd now persists the values it was
    already receiving from pi-adapter.ts.
  • IncludesStep / EntityTimelineStepItem surface the new fields,
    and the three .select() blocks that materialize step rows include
    them.
  • The cached agent_response section grows a
    tokens?: { input?, output? } summed across the run's steps at
    section-build time, and the fingerprintRun cache key includes
    per-step token deltas so a late-arriving onStepEnd invalidates a
    stale cached section.
  • New <TokenUsage> component in agents-server-ui with
    tabular-nums so digits don't jitter, locale-aware compact
    formatting via Intl.NumberFormat. Renders next to <ElapsedTime>
    in both the live and cached meta rows.

Test plan

  • pnpm typecheck clean in agents-runtime + agents-server-ui
  • pnpm test in agents-server-ui (66 passed)
  • pnpm test outbound-bridge use-chat entity-timeline in
    agents-runtime (74 passed)
  • Full agents-runtime test suite: my branch matches the same
    pre-existing 401 failures observed on clean main (unrelated
    permission-system breakage in the test harness, not introduced
    by this PR)
  • Manual: launch a turn that uses tools and watch the counter
    jump at each step boundary
  • Manual: pure-text turn — counter lands once at done

Notes

  • Historical responses recorded before this change have no token data
    persisted (older steps rows lack the columns). The tokens field
    is conditional on at least one step reporting a number, so those
    sections continue to render with no token row instead of "0 / 0".
  • Display format 1.2k ↑ 412 ↓ chosen for compactness in the meta
    row. Open to changing to 1.2k in / 412 out or similar if the
    arrow direction is unclear — input goes up to the model, output
    comes down.

🤖 Generated with Claude Code

Sums input/output tokens across every step of the run and renders them
next to the elapsed-time ticker (e.g. `Thinking · 12s · 1.2k ↑ 412 ↓`).
Counter updates at step boundaries — the LLM SDK only reports `usage`
at end-of-step, so within a single text stream the value stays flat;
tool-using runs see jumps as each step settles.

Token plumbing (additive, no migration):

- `StepValue` Zod + TS gains optional `input_tokens` / `output_tokens`
- `outbound-bridge.ts:onStepEnd` now persists the `tokenInput` /
  `tokenOutput` values it was already receiving but dropping
- `IncludesStep` / `EntityTimelineStepItem` and the three step
  `.select()` blocks surface the new fields
- The cached `agent_response` section gets a summed `tokens?: { input?,
  output? }`, and the section-cache fingerprint includes per-step token
  deltas so a late `onStepEnd` invalidates a stale section
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Electric Agents Desktop Builds

Build artifacts for commit 3f02dc6.

Platform Status Artifact
macOS Apple Silicon Passed DMG
macOS Intel Passed DMG
Windows x64 Passed Installer
Linux x64 Passed AppImage / deb

Workflow run

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

❌ 107 Tests Failed:

Tests completed Failed Passed Skipped
1304 107 1197 4
View the top 3 failed test(s) by shortest run time
test/runtime-dsl.test.ts > G: map-reduce ordering > G3: map-reduce reuses chunk children across later wakes and returns only the latest chunk outputs
Stack Traces | 0.00147s run time
Error: spawn map-reduce-g1/map-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn map-reduce-g1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4602:20
test/runtime-dsl.test.ts > E: observation replay > E0: observe without wake does not re-wake on later child writes
Stack Traces | 0.00148s run time
Error: spawn observed-child-e1/child-0 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3610:19
test/runtime-dsl.test.ts > E: observation replay > E3: an observed row update is replayed as an update, not a second insert
Stack Traces | 0.00149s run time
Error: spawn observed-child-e1/child-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3738:19
test/runtime-dsl.test.ts > D: shared state > D12: mutating one shared collection does not disturb reads from another collection
Stack Traces | 0.00153s run time
Error: spawn ss-writer-d6/ssw-12a failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-writer-d6"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3542:27
test/runtime-dsl.test.ts > F: coordination orchestration > F6: wait_for_all before spawning perspectives returns the documented error path
Stack Traces | 0.00153s run time
Error: spawn manager-f2/manager-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn manager-f2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4029:20
test/runtime-dsl.test.ts > E: observation replay > E2: updating an observed row preserves a single derived row key
Stack Traces | 0.00157s run time
Error: spawn observed-child-e1/child-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3683:19
test/runtime-dsl.test.ts > D: shared state > D8: a later writer can overwrite a shared row and a new reader sees the latest value
Stack Traces | 0.00158s run time
Error: spawn ss-creator-d4/ssw-8a failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-creator-d4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3346:21
test/runtime-dsl.test.ts > F: coordination orchestration > F11: dispatcher preserves counters and child rows when a specialist fails
Stack Traces | 0.00161s run time
Error: spawn dispatcher-f1/dispatch-11 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn dispatcher-f1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4317:20
test/runtime-dsl.test.ts > J: debate coordination > J3: debate with only one durable side stays partial until the missing side arrives
Stack Traces | 0.00165s run time
Error: spawn debate-parent-j1/debate-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn debate-parent-j1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5330:20
test/runtime-dsl.test.ts > F: coordination orchestration > F5: dispatcher returns the documented placeholder when a child produces no text
Stack Traces | 0.00166s run time
Error: spawn dispatcher-f1/dispatch-4 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn dispatcher-f1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4005:20
test/runtime-dsl.test.ts > D: shared state > D10: separate entities can contribute to different collections in one shared state
Stack Traces | 0.00166s run time
Error: spawn ss-writer-d6/ssw-10a failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-writer-d6"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3447:21
test/runtime-dsl.test.ts > F: coordination orchestration > F10: manager-worker can retry after a targeted failure and later collect full results
Stack Traces | 0.00167s run time
Error: spawn manager-f2/manager-6 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn manager-f2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4223:20
test/runtime-dsl.test.ts > B: spawn mechanics > B4: spawn marks the child manifest row as observed
Stack Traces | 0.0017s run time
Error: spawn obs-parent-b4/op-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn obs-parent-b4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3079:20
test/runtime-dsl.test.ts > H: pipeline sequencing > H4: pipeline persists stage-by-stage currentInput updates through the run
Stack Traces | 0.0017s run time
Error: spawn pipeline-h1/pipeline-4 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn pipeline-h1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4778:20
test/runtime-dsl.test.ts > D: shared state > D7: multiple entities can contribute durable rows to the same shared collection
Stack Traces | 0.00171s run time
Error: spawn ss-creator-d4/ssw-7a failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-creator-d4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3310:21
test/runtime-dsl.test.ts > E: observation replay > E1: observed effects do not duplicate old child rows after parent re-wake
Stack Traces | 0.00171s run time
Error: spawn observed-child-e1/child-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3637:19
test/runtime-dsl.test.ts > D: shared state > D1: mkdb produces entity history with a manifest entry
Stack Traces | 0.00171s run time
Error: spawn ss-creator-d1/ssc-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-creator-d1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3124:20
test/runtime-dsl.test.ts > N: wake primitives verification > N5: runFinished wake records the finished child on the parent stream
Stack Traces | 0.00172s run time
Error: spawn wake-summary-parent-n4/wake-summary-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wake-summary-parent-n4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6253:20
test/runtime-dsl.test.ts > F: coordination orchestration > F8: repeated spawn_perspectives reuses the same child streams for later questions
Stack Traces | 0.00172s run time
Error: spawn manager-f2/manager-4 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn manager-f2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4098:20
test/runtime-dsl.test.ts > F: coordination orchestration > F3: dispatcher increments dispatch count and keeps both child rows across wakes
Stack Traces | 0.00172s run time
Error: spawn dispatcher-f1/dispatch-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn dispatcher-f1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3921:20
test/runtime-dsl.test.ts > F: coordination orchestration > F7: manager-worker uses placeholders when every perspective child is silent
Stack Traces | 0.00173s run time
Error: spawn manager-f2/manager-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn manager-f2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4064:20
test/runtime-dsl.test.ts > D: shared state > D2: shared state stream exists even before any writes
Stack Traces | 0.00174s run time
Error: spawn ss-creator2-d2/ssc-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-creator2-d2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3134:20
test/runtime-dsl.test.ts > D: shared state > D9: a setup-registered shared-state effect fires on the first wake write and survives a later wake
Stack Traces | 0.00175s run time
Error: spawn ss-effect-d9/sse-9 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-effect-d9"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3400:20
test/runtime-dsl.test.ts > M: deep researcher coordination > M1: researcher workers start from spawn initialMessage without an extra send
Stack Traces | 0.00176s run time
Error: spawn deep-researcher-m1/research-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn deep-researcher-m1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4917:20
test/runtime-dsl.test.ts > F: coordination orchestration > F4: dispatcher records the expected status progression during a dispatch
Stack Traces | 0.00177s run time
Error: spawn dispatcher-f1/dispatch-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn dispatcher-f1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3975:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A13: failing tools close the run cleanly with durable failure history
Stack Traces | 0.00177s run time
Error: spawn toolful-a9/tool-fail-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn toolful-a9"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3005:20
test/runtime-dsl.test.ts > D: shared state > D3: writes to shared state are reflected in both histories
Stack Traces | 0.00178s run time
Error: spawn ss-writer-d3/ssw-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-writer-d3"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3145:20
test/runtime-dsl.test.ts > D: shared state > D4: a second entity can connect to existing shared state and read prior rows
Stack Traces | 0.00178s run time
Error: spawn ss-creator-d4/ssc-4 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-creator-d4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3157:20
test/runtime-dsl.test.ts > G: map-reduce ordering > G2: map-reduce with one chunk still uses the orchestration path
Stack Traces | 0.00178s run time
Error: spawn map-reduce-g1/map-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn map-reduce-g1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4561:20
test/runtime-dsl.test.ts > C: state collections > C3: self-authored state writes do not trigger a second run
Stack Traces | 0.0018s run time
Error: spawn state-loop-c3/loop-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn state-loop-c3"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3105:20
test/runtime-dsl.test.ts > K: wiki coordination > K7: get_wiki_status before creating a wiki reports the empty state
Stack Traces | 0.0018s run time
Error: spawn wiki-parent-k1/wiki-7 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5670:20
test/runtime-dsl.test.ts > D: shared state > D6: multi-collection shared state stays consistent across writer and reader entities
Stack Traces | 0.0018s run time
Error: spawn ss-writer-d6/ssw-6 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-writer-d6"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3272:20
test/runtime-dsl.test.ts > B: spawn mechanics > B3: spawn manifest history includes the resolved entityUrl
Stack Traces | 0.0018s run time
Error: spawn spawner-b3/s-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn spawner-b3"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3071:20
test/runtime-dsl.test.ts > L: reactive observation flows > L5: one watcher can observe multiple children and preserve source attribution
Stack Traces | 0.00181s run time
Error: spawn observed-child-e1/child-l5-a failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6093:20
test/runtime-dsl.test.ts > C: state collections > C1: ctx.state inserts are reflected in full stream history
Stack Traces | 0.00181s run time
Error: spawn state-writer-c1/sw-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn state-writer-c1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3089:20
test/runtime-dsl.test.ts > K: wiki coordination > K5: query_wiki before any specialist articles exist returns the empty-state message
Stack Traces | 0.00181s run time
Error: spawn wiki-parent-k1/wiki-5 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5597:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A9: sync tool calls appear in-order within one completed run
Stack Traces | 0.00182s run time
Error: spawn toolful-a9/tool-sync-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn toolful-a9"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2923:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A8: manifest history includes the configured agent
Stack Traces | 0.00183s run time
Error: spawn manifested-a8/mf-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn manifested-a8"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2915:20
test/runtime-dsl.test.ts > F: coordination orchestration > F9: manager-worker records a targeted child failure and uses a placeholder only for that perspective
Stack Traces | 0.00184s run time
Error: spawn manager-f2/manager-5 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn manager-f2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4155:20
test/runtime-dsl.test.ts > J: debate coordination > J2: end_debate before any arguments exist returns the empty-state error path
Stack Traces | 0.00184s run time
Error: spawn debate-parent-j1/debate-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn debate-parent-j1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5295:20
test/runtime-dsl.test.ts > N: wake primitives verification > N2: observe(db(...)) with wake option triggers re-wake on shared state write
Stack Traces | 0.00184s run time
Error: spawn ss-wake-writer-n2/ss-writer-n2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-wake-writer-n2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6188:20
test/runtime-dsl.test.ts > K: wiki coordination > K1: wiki specialists accumulate shared articles that a later query can read
Stack Traces | 0.00184s run time
Error: spawn wiki-parent-k1/wiki-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5387:20
test/runtime-dsl.test.ts > K: wiki coordination > K6: repeating create_wiki with the same topic and subtopics is idempotent
Stack Traces | 0.00184s run time
Error: spawn wiki-parent-k1/wiki-6 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5632:20
test/runtime-dsl.test.ts > L: reactive observation flows > L4: watching the same child twice stays deduped
Stack Traces | 0.00185s run time
Error: spawn observed-child-e1/child-l4 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6043:19
test/runtime-dsl.test.ts > A: basic entity lifecycle > A5c: t.waitForSettled waits for runtime quiescence
Stack Traces | 0.00185s run time
Error: spawn multi-a5/m-settled-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn multi-a5"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2888:20
test/runtime-dsl.test.ts > K: wiki coordination > K4: create_wiki rejects switching the topic on an existing wiki
Stack Traces | 0.00185s run time
Error: spawn wiki-parent-k1/wiki-4 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5548:20
test/runtime-dsl.test.ts > L: reactive observation flows > L3: a child delete while the watcher is asleep replays as one delete notice
Stack Traces | 0.00188s run time
Error: spawn observed-child-e1/child-l3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5980:19
test/runtime-dsl.test.ts > A: basic entity lifecycle > A5: multiple messages produce two completed runs
Stack Traces | 0.00188s run time
Error: spawn multi-a5/m-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn multi-a5"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2866:20
test/runtime-dsl.test.ts > K: wiki coordination > K3: get_wiki_status reports complete coverage after specialist articles land
Stack Traces | 0.00188s run time
Error: spawn wiki-parent-k1/wiki-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5523:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A5b: entity.waitForSettled returns the settled history without run-count polling
Stack Traces | 0.00188s run time
Error: spawn multi-a5/m-settled-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn multi-a5"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2877:20
test/runtime-dsl.test.ts > D: shared state > D5: shared state update and delete events remain durable across wakes
Stack Traces | 0.00189s run time
Error: spawn ss-creator-d4/ssc-5 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-creator-d4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3197:20
test/runtime-dsl.test.ts > N: wake primitives verification > N1: WakeEvent type is "wake" when parent is re-woken by child completion
Stack Traces | 0.00189s run time
Error: spawn wake-type-parent-n1/wake-type-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wake-type-parent-n1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6142:20
test/runtime-dsl.test.ts > J: debate coordination > J1: debate parent reads both sides from shared state before issuing a ruling
Stack Traces | 0.00191s run time
Error: spawn debate-parent-j1/debate-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn debate-parent-j1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5223:20
test/runtime-dsl.test.ts > K: wiki coordination > K2: repeating create_wiki reuses existing specialists and only spawns missing subtopics
Stack Traces | 0.00192s run time
Error: spawn wiki-parent-k1/wiki-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5436:20
test/runtime-dsl.test.ts > H: pipeline sequencing > H3: pipeline status caps at stage_5 while longer pipelines still complete
Stack Traces | 0.00193s run time
Error: spawn pipeline-h1/pipeline-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn pipeline-h1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4742:20
test/runtime-dsl.test.ts > I: peer review coordination > I4: peer review with two configured reviewers summarizes only those durable rows
Stack Traces | 0.00193s run time
Error: spawn peer-review-i1/review-4 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn peer-review-i1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5183:20
test/runtime-dsl.test.ts > I: peer review coordination > I2: summarize_reviews before any reviews exist returns the empty-state error path
Stack Traces | 0.00193s run time
Error: spawn peer-review-i1/review-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn peer-review-i1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5112:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A12: stateful note writes persist across wakes and can be read later
Stack Traces | 0.00193s run time
Error: spawn toolful-a9/tool-note-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn toolful-a9"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2976:20
test/runtime-dsl.test.ts > C: state collections > C2: setup-initialized state remains visible in final history
Stack Traces | 0.00194s run time
Error: spawn status-entity-c2/se-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn status-entity-c2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3097:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A10: async tool completion preserves a single clean run history
Stack Traces | 0.00194s run time
Error: spawn toolful-a9/tool-async-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn toolful-a9"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2944:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A11: repeated tool calls keep ordering stable and use the last result
Stack Traces | 0.00194s run time
Error: spawn toolful-a9/tool-double-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn toolful-a9"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2959:20
test/runtime-dsl.test.ts > K: wiki coordination > K9: idempotent wiki recreation does not duplicate shared article rows
Stack Traces | 0.00195s run time
Error: spawn wiki-parent-k1/wiki-9 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5762:20
test/runtime-dsl.test.ts > I: peer review coordination > I1: peer review aggregates three reviewer writes through shared state
Stack Traces | 0.00195s run time
Error: spawn peer-review-i1/review-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn peer-review-i1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5051:20
test/runtime-dsl.test.ts > F: coordination orchestration > F2: manager-worker spawns, observes, and later collects all perspectives in a stable order
Stack Traces | 0.00195s run time
Error: spawn manager-f2/manager-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn manager-f2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3818:20
test/runtime-dsl.test.ts > L: reactive observation flows > L2: re-waking the watcher without new child changes does not duplicate prior observation notices
Stack Traces | 0.00198s run time
Error: spawn observed-child-e1/child-l2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5921:19
test/runtime-dsl.test.ts > G: map-reduce ordering > G4: map-reduce uses a placeholder only for the failed chunk while keeping the others
Stack Traces | 0.00198s run time
Error: Expected 1 additional wake error(s), but they did not occur
 ❯ drainRuntimeWakes test/runtime-dsl.ts:589:15
 ❯ waitForRuntimeSettled test/runtime-dsl.ts:619:5
 ❯ Object.waitForSettled test/runtime-dsl.ts:929:7
 ❯ test/runtime-dsl.test.ts:2806:3
test/runtime-dsl.test.ts > H: pipeline sequencing > H5: pipeline later runs reuse stage children but reset to the latest input chain
Stack Traces | 0.002s run time
Error: spawn pipeline-h1/pipeline-5 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn pipeline-h1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4818:20
test/runtime-dsl.test.ts > H: pipeline sequencing > H6: pipeline carries a failed stage forward as placeholder input for later stages
Stack Traces | 0.002s run time
Error: spawn pipeline-h1/pipeline-6 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn pipeline-h1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4862:20
test/runtime-dsl.test.ts > B: spawn mechanics > B2: spawn with initial message writes the child history
Stack Traces | 0.00201s run time
Error: spawn parent2-b2/p-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn parent2-b2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3059:20
test/runtime-dsl.test.ts > K: wiki coordination > K10: same-topic wiki expansion adds only the missing article and updates later query coverage
Stack Traces | 0.00203s run time
Error: spawn wiki-parent-k1/wiki-10 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5793:20
test/runtime-dsl.test.ts > M: deep researcher coordination > M3: separate researcher entities keep child results isolated across later wakes
Stack Traces | 0.00205s run time
Error: spawn deep-researcher-m1/research-3a failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn deep-researcher-m1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4970:19
test/runtime-dsl.test.ts > K: wiki coordination > K8: wiki keeps durable child metadata and shared articles carry topic and author details
Stack Traces | 0.00205s run time
Error: spawn wiki-parent-k1/wiki-8 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wiki-parent-k1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5690:20
test/runtime-dsl.test.ts > I: peer review coordination > I3: peer review with one configured reviewer summarizes only that durable row
Stack Traces | 0.00207s run time
Error: spawn peer-review-i1/review-3 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn peer-review-i1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5145:20
test/runtime-dsl.test.ts > L: reactive observation flows > L1: explicit observe plus createEffect forwards insert, update, and delete notices
Stack Traces | 0.00208s run time
Error: spawn observed-child-e1/child-l1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn observed-child-e1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:5860:19
test/runtime-dsl.test.ts > A: basic entity lifecycle > A7: setup state writes appear before the run history
Stack Traces | 0.00214s run time
Error: spawn stateful-a7/s-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn stateful-a7"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2906:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A14: an entity can recover from a failed tool call in a later run
Stack Traces | 0.00218s run time
Error: spawn toolful-a9/tool-recover-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn toolful-a9"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3019:20
test/runtime-dsl.test.ts > N: wake primitives verification > N4: ctx.agent.run receives the wake payload and performs a second run on child completion
Stack Traces | 0.0022s run time
Error: spawn idle-wake-parent-n3/wake-agent-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn idle-wake-parent-n3"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6226:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A4: agent text output is reflected in the final history
Stack Traces | 0.00223s run time
Error: spawn texter-a4/t-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn texter-a4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2857:20
test/runtime-dsl.test.ts > H: pipeline sequencing > H2: pipeline feeds each stage the previous stage output and persists final state
Stack Traces | 0.00231s run time
Error: spawn pipeline-h1/pipeline-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn pipeline-h1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4712:20
test/runtime-dsl.test.ts > H: pipeline sequencing > H1: pipeline writes its state row during the first wake before stage execution
Stack Traces | 0.00232s run time
Error: spawn pipeline-h1/pipeline-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn pipeline-h1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4690:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A3: single message produces a full run history
Stack Traces | 0.00233s run time
Error: spawn runner-a3/r-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn runner-a3"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2849:20
test/runtime-dsl.test.ts > F: coordination orchestration > F12: dispatcher preserves counters and child rows across repeated failing dispatches
Stack Traces | 0.0024s run time
Error: spawn dispatcher-f1/dispatch-12 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn dispatcher-f1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4391:20
test/runtime-dsl.test.ts > G: map-reduce ordering > G1: map-reduce returns results in chunk order even when completions differ
Stack Traces | 0.00241s run time
Error: spawn map-reduce-g1/map-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn map-reduce-g1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4507:20
test/runtime-dsl.test.ts > B: spawn mechanics > B1: spawn creates a child entity that can receive messages
Stack Traces | 0.00251s run time
Error: spawn parent-b1/p-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn parent-b1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3046:20
test/runtime-dsl.test.ts > M: deep researcher coordination > M2: wait_for_results before spawning researchers returns the empty-state error path
Stack Traces | 0.00301s run time
Error: spawn deep-researcher-m1/research-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn deep-researcher-m1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:4944:20
test/runtime-dsl.test.ts > D: shared state > D11: adjacent writers contending on the same shared key preserve full history and last-write-wins
Stack Traces | 0.00308s run time
Error: spawn ss-creator-d4/ssw-11a failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn ss-creator-d4"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3490:21
test/runtime-dsl.test.ts > A: basic entity lifecycle > A2: spawn with initial message writes inbox history before any run
Stack Traces | 0.00308s run time
Error: spawn basic-a2/b-2 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn basic-a2"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2828:20
test/runtime-dsl.test.ts > N: wake primitives verification > N3: wake events are delivered as wake when the parent is re-woken
Stack Traces | 0.00316s run time
Error: spawn wake-type-parent-n1/idle-test-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn wake-type-parent-n1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6346:20
test/runtime-dsl.test.ts > F: coordination orchestration > F1: dispatcher routes to the requested specialist type and records the child
Stack Traces | 0.00331s run time
Error: spawn dispatcher-f1/dispatch-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn dispatcher-f1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:3795:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A6: agent-less entity records only inbound messages
Stack Traces | 0.0036s run time
Error: spawn noagent-a6/na-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn noagent-a6"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2898:20
test/runtime-dsl.test.ts > A: basic entity lifecycle > A1: spawn writes entity_created immediately with spawn args
Stack Traces | 0.0244s run time
Error: spawn basic-a1/b-1 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn basic-a1"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:2811:20
View the full list of 17 ❄️ flaky test(s)
test/dispatch-policy-routing.test.ts > dispatch policy routing > creates pull-wake subscriptions for runner-targeted spawns

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.0395s run time
AssertionError: expected 500 to be 201 // Object.is equality

- Expected
+ Received

- 201
+ 500

 ❯ test/dispatch-policy-routing.test.ts:115:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > creates webhook subscriptions and stores the original target

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.00077s run time
AssertionError: expected 500 to be 201 // Object.is equality

- Expected
+ Received

- 201
+ 500

 ❯ test/dispatch-policy-routing.test.ts:173:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > does not re-add already linked runner streams before sending

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.000828s run time
AssertionError: expected 500 to be 204 // Object.is equality

- Expected
+ Received

- 204
+ 500

 ❯ test/dispatch-policy-routing.test.ts:360:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > links legacy entities through the type default before sending

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.00214s run time
AssertionError: expected 500 to be 204 // Object.is equality

- Expected
+ Received

- 204
+ 500

 ❯ test/dispatch-policy-routing.test.ts:286:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > links pull-wake dispatch before sending spawn initialMessage

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.000863s run time
AssertionError: expected 500 to be 201 // Object.is equality

- Expected
+ Received

- 201
+ 500

 ❯ test/dispatch-policy-routing.test.ts:204:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > links webhook dispatch before sending spawn initialMessage

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.000773s run time
AssertionError: expected 500 to be 201 // Object.is equality

- Expected
+ Received

- 201
+ 500

 ❯ test/dispatch-policy-routing.test.ts:244:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > recreates missing runner dispatch subscriptions before sending

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.000862s run time
AssertionError: expected 500 to be 204 // Object.is equality

- Expected
+ Received

- 204
+ 500

 ❯ test/dispatch-policy-routing.test.ts:321:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > treats runner subscription create conflicts as an idempotent spawn link

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.000851s run time
AssertionError: expected 500 to be 201 // Object.is equality

- Expected
+ Received

- 201
+ 500

 ❯ test/dispatch-policy-routing.test.ts:419:29
test/dispatch-policy-routing.test.ts > dispatch policy routing > uses separate pull-wake subscriptions for separate runner-targeted entities

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.00174s run time
AssertionError: expected 500 to be 201 // Object.is equality

- Expected
+ Received

- 201
+ 500

 ❯ test/dispatch-policy-routing.test.ts:149:26
test/electric-agents-manager-write-validation.test.ts > ElectricAgentsManager event source subscriptions > persists subscription deletion before unregistering wake side effects

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.00061s run time
TypeError: this.registry.replaceSharedStateLink is not a function
 ❯ EntityManager.syncManifestLinks src/entity-manager.ts:3052:25
 ❯ EntityManager.writeManifestEntry src/entity-manager.ts:2660:5
 ❯ EntityManager.deleteEventSourceSubscription src/entity-manager.ts:2898:5
 ❯ test/electric-agents-manager-write-validation.test.ts:250:5
test/electric-agents-manager-write-validation.test.ts > ElectricAgentsManager event source subscriptions > persists the manifest before registering wake side effects

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.00571s run time
TypeError: this.registry.replaceSharedStateLink is not a function
 ❯ EntityManager.syncManifestLinks src/entity-manager.ts:3052:25
 ❯ EntityManager.writeManifestEntry src/entity-manager.ts:2660:5
 ❯ EntityManager.upsertEventSourceSubscription src/entity-manager.ts:2859:5
 ❯ test/electric-agents-manager-write-validation.test.ts:210:5
test/electric-agents-status.test.ts > ElectricAgentsManager.forkSubtree > forks durable streams before registering remapped entity rows

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.00891s run time
TypeError: this.registry.replaceSharedStateLink is not a function
 ❯ EntityManager.syncManifestLinks src/entity-manager.ts:3052:25
 ❯ EntityManager.materializeForkManifestSideEffects src/entity-manager.ts:2050:7
 ❯ EntityManager.forkSubtreeInner src/entity-manager.ts:1141:11
 ❯ src/entity-manager.ts:876:22
 ❯ src/tracing.ts:32:14
 ❯ withSpan src/tracing.ts:30:10
 ❯ EntityManager.forkSubtree src/entity-manager.ts:874:12
 ❯ test/electric-agents-status.test.ts:478:20
test/event-source-subscriptions-route.test.ts > event source subscription routes > creates a manifest-backed webhook wake subscription

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.029s run time
TypeError: ctx.entityManager.registry.hasEntityPermission is not a function
 ❯ canAccessEntity src/permissions.ts:40:39
 ❯ src/routing/entities-router.ts:713:9
 ❯ fetch ../../node_modules/.pnpm/itty-router@5.0..../node_modules/itty-router/index.mjs:1:1266
 ❯ Object.fetch ../../node_modules/.pnpm/itty-router@5.0..../node_modules/itty-router/index.mjs:1:1266
 ❯ test/event-source-subscriptions-route.test.ts:29:22
test/event-source-subscriptions-route.test.ts > event source subscription routes > rejects subscriptions whose params do not match the bucket schema

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 0.000583s run time
TypeError: ctx.entityManager.registry.hasEntityPermission is not a function
 ❯ canAccessEntity src/permissions.ts:40:39
 ❯ src/routing/entities-router.ts:713:9
 ❯ fetch ../../node_modules/.pnpm/itty-router@5.0..../node_modules/itty-router/index.mjs:1:1266
 ❯ Object.fetch ../../node_modules/.pnpm/itty-router@5.0..../node_modules/itty-router/index.mjs:1:1266
 ❯ test/event-source-subscriptions-route.test.ts:135:22
test/runtime-dsl.test.ts > N: wake primitives verification > N3b: spawn wake and child manifest share one runFinished registration

Flake rate in main: 100.00% (Passed 0 times, Failed 5 times)

Stack Traces | 0.00178s run time
Error: spawn idle-wake-parent-n3/idle-test-dedupe-1780575869695 failed (401): {"error":{"code":"UNAUTHORIZED","message":"Principal is not allowed to spawn idle-wake-parent-n3"}}
 ❯ Object.spawnEntity src/runtime-server-client.ts:444:13
 ❯ timeStep test/runtime-dsl.ts:236:12
 ❯ Object.spawn test/runtime-dsl.ts:894:22
 ❯ test/runtime-dsl.test.ts:6302:20
test/sandbox-conformance.test.ts > sandbox conformance > docker > exec returns immediately when signal is already aborted

Flake rate in main: 100.00% (Passed 0 times, Failed 4 times)

Stack Traces | 5s run time
Error: Test timed out in 5000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
 ❯ test/sandbox-conformance.test.ts:474:53
test/server-start.test.ts > ElectricAgentsServer.start > rehydrates pending future_send manifest schedules on startup

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.0022s run time
AssertionError: expected "vi.fn()" to be called with arguments: [ '/chat/test', …(3) ]

Number of calls: 0

 ❯ test/server-start.test.ts:356:50

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Electric Agents Mobile Build

Local mobile checks ran for commit 3f02dc6.

The EAS Android preview build was skipped because the mobile-eas-build label is not present.
Add the mobile-eas-build label to this PR to produce an installable preview build.

Workflow run

Copy link
Copy Markdown
Contributor

@samwillis samwillis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interactive review with GPT.

Thanks for wiring this through. I traced the token usage path end-to-end:

pi-adapter message_end.usage
bridge.onStepEnd({ tokenInput, tokenOutput })
steps.update({ input_tokens, output_tokens })
→ timeline step rows
→ UI meta row.

Overall the stream write looks sound: token usage is attached to the step completion update, so it appears once at the end of a pure text generation step, and jumps at step boundaries for tool-using runs.

A couple of suggestions/questions:

  1. Can we compute the per-run total in the timeline query/view model?

Right now AgentResponseLive subscribes to run.steps and sums input_tokens / output_tokens in React, while buildAgentSection separately performs the same aggregation for materialized sections.

If TanStack DB supports this shape cleanly, I think it would be better to expose a single per-run tokens field from createEntityTimelineQuery / the includes query, e.g. via a scoped aggregate over steps for the run. Then the UI only renders run.tokens / section.tokens, and the aggregation logic lives in one layer.

Since usage only lands at step end, not token-by-token, updating the parent run/timeline row at those boundaries seems acceptable to me.

  1. Missing usage fields currently become real zeroes

In pi-adapter, when msg.usage exists, missing sides are coerced to 0:

...(usage && {
  tokenInput: usage.input ?? usage.inputTokens ?? 0,
  tokenOutput: usage.output ?? usage.outputTokens ?? 0,
}),

Now that these values are persisted and displayed, that can make an unknown side look like a real 0. If pi-ai guarantees both input and output are always present, a small regression test would be useful. Otherwise I’d preserve undefined for missing sides and only write numeric values.

  1. Test coverage

I’d like to see a targeted regression test that proves token usage reaches the steps.update event, and another around the timeline/view-model total if we move the aggregation there. That would lock down the important stream contract introduced by this PR.

@KyleAMathews
Copy link
Copy Markdown
Contributor

👍 yeah just showing total tokens for the run at the bottom makes sense to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants