Skip to content

feat(examples): add a live streaming durable Pi agent demo - #102

Merged
forhappy merged 2 commits into
mainfrom
codex/pi-agent-e2e-qualification
Oct 23, 2026
Merged

forhappy merged 2 commits into
mainfrom
codex/pi-agent-e2e-qualification

Conversation

@forhappy

@forhappy forhappy commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The durable Pi example now has a browser frontend that displays actual provider text while a task runs, shows confirmed tool effects and checkpoints, and restores saved results after reload or worker replacement. This PR also qualifies the installed package and adds opt-in real-provider recovery tests.

Behavior

  • A responsive local task console includes task history, streamed answers, saved receipts, attempt/model-step counts, reconnect handling and a Restart worker control. Text is rendered as text, and unfinished previews are distinguished from committed results.
  • A small loopback Node server serves the frontend and SSE. The runner observes real Pi provider text events while still checkpointing each complete decision before Pi can execute tools. Cellar's Rust/JavaScript HTTP bridge remains buffered; durable state remains in Cellar.
  • The launcher starts the real Rust host, keeps its development bucket across replacement, uses fresh node identities/storage directories, and joins the worker on shutdown. Browser/gateway failures cannot fail durable execution. Bounded buffers, slow-reader disconnection, Host/Origin checks and a rotating observer token protect the local observation channel. Credentials and thinking blocks never enter browser events.
  • The captured runtime includes frontend/launcher assets. The installed-package integration test covers eight concurrent tasks, invalid/conflicting HTTP requests, cold SIGKILL recovery and 32 duplicate submissions. Each Rust test uses a scoped execution domain so both package scenarios can run together.

Run

After the README build steps, launch from the repository root:

CELLAR_PI_HOST="$CARGO_TARGET_DIR/debug/cellar-pi-agent-example" \
  node --env-file=/path/to/openai.env examples/pi-agent/demo/launch.mjs

Open http://127.0.0.1:4317. The default is OpenAI gpt-4.1-mini with real provider charges; CELLAR_PI_PROVIDER=fixture is the explicitly labeled no-credentials alternative. The README documents ports, persistent data, streaming semantics, recovery and repeatable live tests.

Validation

Locally on macOS arm64, Node 24.13.1 and Rust 1.98.1:

  • 15 tests passed, including deltas arriving before the final checkpoint, observer failure isolation, sync-proof ordering, SSE reconnect, origin/token rejection, token rotation during an in-flight body and cleanup after launcher startup failure.
  • All six existing native-host crash scenarios passed with the updated runner.
  • Live OpenAI browser task completed with counter 7, one receipt and 132 text events; page reload preserved its answer/result. Desktop and 390px mobile flows were inspected, screenshots captured, and browser console had no errors/warnings.
  • Opt-in live streaming qualification interrupted the host on the first actual text delta, before the final model response was checkpointed. Attempt 2 streamed again and reused the tool receipt. Counter stayed 13, receipts stayed 1, model checkpoints totaled 2, and duplicate submission returned an identical result. The report captured 241 text events across both attempts.
  • The rebuilt installed package passed eight concurrent tasks, SIGKILL/cold recovery with identical transcripts and 32 concurrent duplicate submissions. Both Node and Pi package tests also passed together in the earlier qualification.
  • Real Rust demo launcher startup, SIGTERM shutdown/join and lock cleanup passed. Format/layout, native dependency policy, docs checks and frontend syntax checks passed. Existing affected-crate Clippy qualification passed before this frontend-only addition.
  • Earlier live tests also passed tool-commit and completed-task crashes with gpt-4.1-mini.

Live tests are opt-in; CI's model fixture does not make paid requests. No credentials, generated screenshots, reports or binaries are committed. This remains a bounded local development demo: previews are ephemeral, interrupted uncheckpointed provider requests may repeat, and arbitrary external tools require their own downstream idempotency/reconciliation. Production authentication, multi-host preview routing and production fleet fault qualification are outside this example.

@forhappy forhappy changed the title test(javascript): qualify durable Pi agents end to end feat(examples): add a live streaming durable Pi agent demo Oct 23, 2026
@forhappy
forhappy merged commit 64ebaf7 into main Oct 23, 2026
5 of 9 checks passed
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.

1 participant