Skip to content

fix(pi-dev): port pi-watch to pi 1.x, fail on provider errors, refresh alias ladders - #48

Merged
zpyoung merged 2 commits into
mainfrom
zpyoung/fix-pi-watch
Oct 15, 2026
Merged

zpyoung merged 2 commits into
mainfrom
zpyoung/fix-pi-watch

Conversation

@zpyoung

@zpyoung zpyoung commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

pi-watch works with pi-coding-agent 1.x again. It now exits 1 with the provider's error when a dispatch fails, instead of printing an empty reply and exiting 0. Its aliases now resolve to the GPT-6 and Claude 5.5 models in the 1.x catalog.

The 1.x port (DEFER-16)

Every fresh install crashed on import (does not provide an export named 'AuthStorage'). package.json allowed any version, and the SDK replaced AuthStorage and ModelRegistry with ModelRuntime back in 0.80.8.

  • pi-watch.mjs builds a ModelRuntime and hands it to createAgentSession. It also adds the two methods the 1.x ResourceLoader requires and sets cacheWarming: "off", since a one-shot run never reuses the cache those extra paid requests would keep warm.
  • The SDK is pinned to ^1.2.0. I tried ^1.0.0 first, but a fresh install of 1.0.0 or 1.1.0 crashes upstream: they take any pi-codemode 1.x, and pi-codemode 1.2.0 dropped an export they import.
  • The launcher now reinstalls deps when they're older than that pin, not only when they're missing. That catches old installs like the 0.80.7 workaround pin.
  • The new pnpm-workspace.yaml declines the @google/genai and protobufjs build scripts. pnpm 12 exits 1 on unapproved builds, which made the launcher's own reinstall fail. pi-watch doesn't need either script.

Failed dispatches now exit 1 (BUG-12)

A failed provider request doesn't throw. session.prompt() returns normally and marks the final reply with an error status. pi-watch never checked it, so an expired login looked like an empty review to callers such as adversarial-review. It now reads that reply the way pi -p does:

  • error or aborted: exit 1 with the error message
  • cut off at the output token limit: exit 1, saying the reply was truncated

This check runs before --require-trailer, so these failures exit 1 instead of 6.

Alias ladders for the 1.x catalog (DEFER-17)

  • codex and codex-max now lead with GPT-6.1 Sol and GPT-6 Sol. codex-mini leads with GPT-6 Luna, and sonnet, opus and haiku lead with Claude 5.5.
  • The new opt-in fable alias covers Claude Fable 5.1 and 5. It costs 2.5× Opus 5.5, so it isn't in the opus ladder.
  • grok now routes to grok-4.7 and 4.6, via xai first and then Copilot. grok-code-fast-1 is no longer in the catalog, so the old ladder could never resolve.
  • GPT-6 Astra ($10/$50) is excluded like the pro tiers. GPT-6 has no Terra tier, so terra stays on GPT-5.6 Terra.
  • I removed entries the pinned pi-ai 1.2.0 catalog doesn't ship, such as gemini-3.2-pro-preview and claude-sonnet-4-7. If an older pi binary listed one of them, resolution stopped on it with an SDK-skew error instead of falling through to the next entry.
  • --where now checks for gpt-6.1-sol, and the default model at the top of each adversarial-review ALIAS_LADDER rung matches the new ladders.
  • In models.md, the PI_AVAILABLE snippet piped only stderr, which comes back empty on pi 1.x. It now reads both streams.

Testing

All runs used the SDK at 1.2.0.

  • --list-aliases and --check work; 10 of 11 aliases are ready (grok isn't logged in).
  • A Gemini Flash dispatch prints OK and exits 0.
  • A codex-mini dispatch with the read tool and --require-trailer exits 0.
  • With the expired Anthropic login, --alias sonnet exits 1 with OAuth refresh failed … invalid_grant. Before this change it exited 0 with an empty reply.
  • The launcher reinstall works when deps are stale (0.80.7), missing, or already current (no reinstall).
  • With pi 1.2.0 on PATH, --check resolves codex → openai/gpt-6.1-sol, codex-mini → gpt-6-luna, sonnet / opus / haiku → Claude 5.5 and fable → claude-fable-5-1. grok is ✗ because xai and Copilot aren't logged in here.
  • Real codex (GPT-6.1 Sol), codex-mini (GPT-6 Luna) and flash dispatches print OK.
  • Every ladder entry exists in the pi-ai 1.2.0 catalog.
  • Full pytest -q: 1285 passed, 1 skipped.

Still open: BUG-9 (--check marks an alias ready when its login has expired) and DEFER-18 (the per-provider model dumps in models.md are a pre-1.x snapshot).

pi-watch crashed on import with any pi-coding-agent from 0.80.8 on, because
AuthStorage and ModelRegistry were replaced by ModelRuntime.

- Build a ModelRuntime and pass it to createAgentSession
- Pin the SDK to ^1.2.0; 1.0.0 and 1.1.0 break on fresh installs upstream
- Launcher reinstalls deps that are missing or older than the pin
- Commit pnpm-workspace.yaml so pnpm 12's install doesn't exit 1
- Exit 1 with the provider's error when the final reply errored, aborted,
  or hit the token limit, instead of exiting 0 with an empty reply

Resolves DEFER-16 and BUG-12. Logs DEFER-17 (alias ladders lag pi 1.x).
Copilot AI balanced review requested due to automatic review settings October 15, 2026 14:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

- codex/codex-max lead with GPT-6.1 and GPT-6 Sol, codex-mini with GPT-6 Luna
- sonnet/opus/haiku lead with Claude 5.5
- New opt-in fable alias for Claude Fable 5.1/5
- grok routes to grok-4.7/4.6 via xai, then Copilot; grok-code-fast-1 is gone
- Exclude GPT-6 Astra as pro-priced; terra stays on GPT-5.6 Terra
- Drop entries the pinned pi-ai 1.2.0 catalog doesn't ship
- --where probes for gpt-6.1-sol; adversarial-review ladder heads match
- models.md: fix PI_AVAILABLE snippet for pi 1.x stdout output

Resolves DEFER-17. Logs DEFER-18 (stale per-provider dumps in models.md).
@zpyoung zpyoung changed the title fix(pi-dev): port pi-watch to the pi 1.x SDK and fail on provider errors fix(pi-dev): port pi-watch to pi 1.x, fail on provider errors, refresh alias ladders Oct 15, 2026
@zpyoung
zpyoung merged commit 2b093ec into main Oct 15, 2026
1 check passed
github-actions Bot added a commit that referenced this pull request Oct 15, 2026
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.

2 participants