Skip to content

feat(pi): pi 1.5 + agents 0.33 (watch bridge, restart limit ends work, browser.cdp, models as a function, createAI 0.29 wire) - #153

Closed
jonnyparris wants to merge 8 commits into
mainfrom
feat/pi-1-4-agents-0-30
Closed

jonnyparris wants to merge 8 commits into
mainfrom
feat/pi-1-4-agents-0-30

Conversation

@jonnyparris

@jonnyparris jonnyparris commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Upgrades Dodo from pi 1.3 / agents 0.28 to pi 1.5 (@earendil-works/pi-durable, pi-ai, chord ~1.5.0, plus the new peer @earendil-works/pi-schema) and agents 0.33. They move together: agents 0.33 pins pi ~1.5.0. This PR first targeted pi 1.4 / agents 0.30. It was retargeted before merge so prod takes one storage migration instead of two (see the 1.5 launch note).

⚠️ One-way. pi 1.4+ migrates each session's pi_ tables to schema v2 when it first opens them, and pi 1.5 stores pi.live at version 3. pi 1.3 can't open those tables, and 1.4 can't read pi.live v3. Once this is on prod, a deploy can't roll back past it without breaking every session that 1.5 opened. Fix a bad deploy by rolling forward.

What changed

  • Event bridge (src/pi/live-bridge.ts, new). pi 1.5 removed watchEvents(). PiEngine.run() now attaches Conversation.watch() before it submits the prompt, or before it resumes a recovered run. LiveBridge turns each view into Dodo's SSE events. A watch folds together the commits made while its listener runs, and the view's entries are a window. So the bridge renders the current state instead of replaying events:
    • New transcript entries drive each step's text, tool_call (from the answer's toolCall blocks), tool_result, the step count and token usage.
    • pi.live drives only the streaming partial text, the turn stall guard's snapshot and the log lines.
    • When the view's window was trimmed, the bridge pages in the entries it skipped. After the turn settles, finish() reads any entries that no delivered view showed.
  • Parked-task handling removed. pi 1.5 ends work that hits the restart limit instead of parking it:
    • A tool call cut off 5 times ends with an error result, which the model sees.
    • A model request ends the run unanswered with reason restart_limit.
    • A request that was in flight when the host died counts as a failed attempt. Once retries run out, the run ends interrupted.
    • Both reasons become a plain "send the prompt again" error (piUnansweredMessage).
    • onReport now takes one report tagged by kind, and SessionEnd uses end.kind.
  • Turn stall guard gets a full snapshot on every watch call: the open tool calls (pending ones included) and whether a compaction is running.
  • SETTINGS.progress. Streamed text is now stored in batches. Watches see each update at once, and storage gets them within persistWithinMs (1 s, now set explicitly). The old comment, "250 ms keeps write volume modest", was wrong; partialIntervalMs now only sets how often the chat updates. A crash can lose up to ~1 s of streamed text.
  • browser_execute (agents 0.31). The model's code runs in its own Dynamic Worker and calls a browser global (browser.cdp(...)). notice replaces restarted/newTabs. ctx is gone from the tool options. The wrapper passes structuredOutput through, because the tool now declares a schema for it. The system prompt, the browser-cdp-perf skill and the README teach the new API.
  • MCP peers (agents 0.31). @modelcontextprotocol/server (2.4.0) and sdk (1.32.2) are listed explicitly. agents/mcp imports the server package, and without it the bundle failed to build. Bumping vite to 8.3.5 cleared a peer conflict on esbuild 0.28.
  • Kept from the 1.4 version of this PR:
    • HarnessOptions.models as a function.
    • The createAI 0.29 wire: catalog Anthropic goes over env.AI.run, and routed models go over env.AI.fetch through adaptBindingForCreateAI.
    • The eviction-test fixes.
  • Docs: ADR 0002 now has a "Pi 1.5 / agents 0.33" section, and docs/file-map.md is updated.

Checks

  • tsc (app + bench), biome lint, full vitest: 1419/1419 passed locally. The first full runs had hook timeouts in facet/OAuth tests at load average ~90; those files pass on a re-run. dodo-verify passed on 89cee41.
  • Adversarial review: 3 rounds (Opus 5.5 + Gemini 3.1 pro across 3 lenses, then Haiku + Gemini flash on the fix deltas). 10 findings fixed, 4 refuted with evidence, 2 left open (below).
  • Preview matrix (dodo-preview, under preview-lock):
    • Sessions seeded on main (pi 1.3, eaf26c9): a plain answer, a tool turn, and a fork of the tool turn.
    • Sessions seeded on this PR's old head (pi 1.4, 2777f58): a tool turn and its fork.
    • Then this branch (pi 1.5, 89cee41):
      • All 5 sessions list their messages, and a new prompt in each answers using the earlier context. Both 1.3 → 1.5 and 1.3 → 1.4 → 1.5 work.
      • Forking a 1.3-born session under 1.5 (snapshot import) works, and so does a fresh session.
      • SSE on a tool turn showed tool_call (with args), tool_result, and 3 text_delta frames that add up to exactly the final text.
      • browser_execute with browser.cdp returned the page title. A screenshot came back as an image attachment, in the same tab as the previous call.
    • Test sessions deleted, label removed, and preview handed back (re-ran fix(subagents): send the schema on @cf/ structured coercion, give it room, say 'timed out' #159's preview run).

Known, not fixed here

  • If a provider retry happens after part of an answer has streamed, the chat shows the failed partial, followed by the retry's full text, until the turn ends. The pi 1.4 bridge behaved the same way. Fixing it needs a new SSE "reset" event and a client change.
  • A recovered tool round with more than 23 results (outside the 24-entry first window) shows its calls with {} as input. Its results still show.

…as a function

- @earendil-works/pi-durable, pi-ai, chord ~1.4.0; agents ^0.30.1 (lockstep:
  agents 0.30 peers pin pi ~1.4.0). pi 1.4 migrates pi_ tables to schema v2,
  which 1.3 can't open: no rollback past this deploy.
- PiEngine reads onReport's typed info. A task pi's crash-loop guard parks
  (5 restarts without progress) no longer leaves the turn waiting for the
  15-min stall guard: a recovered prompt whose run is parked is aborted and
  fails with PiTaskParkedError; a new prompt aborts work an earlier turn left
  parked, then runs.
- HarnessOptions.models is a function (PiEngineHost.models()); CodingAgent
  rebuilds Models only when the gateway config changes. Closes the ADR 0002
  Upstream workaround.
- createAI (agents >=0.29) dropped the universal endpoint: main-session
  Anthropic resolves by AI Gateway's catalog spelling (anthropic/claude-*-4.6)
  and runs on env.AI.run, with Dodo's id kept on the model for persisted refs;
  subagent routed models use env.AI.fetch, now wrapped to keep the
  AbortSignal local. Fake AI binding covers both.
- Tests: parked-turn recovery, stale-park clearing, adapter fetch; attach the
  rejection handler before close() in mid-run eviction tests (pi 1.4's close
  rejects pending waits).
…park listener (parks are only counted at open)
…t, keep served models registered mid-run; docs
…del/gateway are frozen while a prompt runs); comments
@jonnyparris jonnyparris added the preview-lock Holds dodo-preview: other PRs' pushes skip the preview deploy until removed label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Preview deployed: https://dodo-preview.jonnyparris.club

Serves 89cee41 from this PR. Access-gated (same policies as prod). Load it in a Browser Run session with the Dodo service token to verify UI changes.

The preview is shared: the next PR push replaces this build, and this PR gets a new comment when that happens. Add the preview-lock label to hold it during a live check, and remove the label when you are done.

Replaced 2777f58 from #153.

@jonnyparris

Copy link
Copy Markdown
Owner Author

beep-boop-🤖 Preview check on 2777f58 (dodo-preview, held with preview-lock from 22:40 to 22:55 UTC). The sessions were seeded at 22:20 on the pi 1.3 build (6e4ec69).

Check Result
Session made on pi 1.3: open on 1.4 (pi_ tables move to schema v2), then a new prompt ✅ history kept: answered alpha, beta
Fork made on pi 1.3 (snapshot export/import): open on 1.4, then a new prompt ✅ alpha, gamma
Main model anthropic/claude-sonnet-4-6 through createAI's catalog env.AI.run path ✅ claude-post, 19k tokens in
Explore subagent on anthropic/claude-haiku-4-5 through routed → env.AI.fetch ✅
POST /debug/evict during a model call ✅ that step was aborted, the turn resumed and completed
POST /debug/evict during a codemode call ✅ the tool came back interrupted (not replay-safe, as designed), the turn completed

Not tested live: a real park. It needs 5 resets with no progress, and Dodo's fiber gives up after 3. The workerd tests in test/pi-engine.test.ts cover the park paths. I deleted the test sessions, because a pi 1.3 build can't open their v2 tables. I removed preview-lock and re-ran #154's preview deploy to hand preview back.

@jonnyparris jonnyparris removed the preview-lock Holds dodo-preview: other PRs' pushes skip the preview deploy until removed label Oct 23, 2026
@jonnyparris
jonnyparris marked this pull request as ready for review October 23, 2026 22:47
@github-actions

Copy link
Copy Markdown

Preview replaced: https://dodo-preview.jonnyparris.club now serves ca629c6 from #154, not this PR's 2777f58.

A live check on this PR that started before now is no longer testing this branch. Re-run this PR's deploy-preview job to take the preview back, or add the preview-lock label to deploy it and hold it.

@jonnyparris jonnyparris added the preview-lock Holds dodo-preview: other PRs' pushes skip the preview deploy until removed label Nov 5, 2026
…mit ends work, browser.cdp tool API)

- @earendil-works/pi-durable, pi-ai, chord ~1.5.0, + pi-schema; agents ^0.33.0;
  @modelcontextprotocol/server (+ sdk 1.32.2): optional peers since agents 0.31,
  agents/mcp imports the server package.
- PiEngine: watchEvents is gone. run() attaches Conversation.watch() before it
  submits; LiveBridge (src/pi/live-bridge.ts) renders each view: transcript
  entries drive text, tool_call/tool_result, steps and usage; pi.live drives
  the streaming partial, the stall guard snapshot and logs. finish() reads what
  no delivered view showed.
- Parked-task handling removed (pi 1.5 ends restart-limited work).
  restart_limit / interrupted map to a plain 'send the prompt again' error
  (piUnansweredMessage). onReport(report) and SessionEnd use the tagged kind.
- SETTINGS.progress: partials are deferred now; comment fixed, persistWithinMs explicit.
- Turn stall guard takes a full live snapshot per watch call.
- browser_execute (agents 0.31): no ctx, structuredOutput passed through;
  system prompt, browser-cdp-perf skill and README teach browser.cdp / notice.
- Docs: ADR 0002 'Pi 1.5 / agents 0.33', file map.
@jonnyparris jonnyparris removed the preview-lock Holds dodo-preview: other PRs' pushes skip the preview deploy until removed label Nov 5, 2026
@jonnyparris jonnyparris changed the title feat(pi): pi 1.4 + agents 0.30 (parked tasks, models as a function, createAI 0.29 wire) feat(pi): pi 1.5 + agents 0.33 (watch bridge, restart limit ends work, browser.cdp, models as a function, createAI 0.29 wire) Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Preview replaced: https://dodo-preview.jonnyparris.club now serves eaf26c9 from #159, not this PR's 89cee41.

A live check on this PR that started before now is no longer testing this branch. Re-run this PR's deploy-preview job to take the preview back, or add the preview-lock label to deploy it and hold it.

@jonnyparris

Copy link
Copy Markdown
Owner Author

beep-boop-🤖 Superseded by #164 (#164), which carried all of this PR's commits and merged into main with a merge commit, so the history is preserved.

jonnyparris added a commit that referenced this pull request Nov 21, 2026
feat(mcp): agents 0.34 + pi 1.6; MCP step-up via MCPAuthorizationRequiredError (stacked on #153)

This branch was successfully deployed

1 active deployment
dodo-preview — 89cee419 Deployed Nov 5, 2026 by github-actions[bot]
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