Skip to content

fix(pi): restore subagent compatibility - #367

Open
hidewong wants to merge 1 commit into
Waishnav:mainfrom
hidewong:fix/pi-model-runtime
Open

hidewong wants to merge 1 commit into
Waishnav:mainfrom
hidewong:fix/pi-model-runtime

Conversation

@hidewong

@hidewong hidewong commented Sep 22, 2026

Copy link
Copy Markdown

Summary

Fresh installs can resolve @earendil-works/pi-coding-agent 0.80.10 from the existing ^0.80.3 range. That release no longer exposes the AuthStorage / ModelRegistry session API used by the Pi adapter, so devspace agents run pi fails during session creation.

This updates the adapter to Pi's ModelRuntime API and pins the embedded SDK to the tested 0.80.10 release so published installs cannot silently drift to another incompatible API. It also adds a default-factory smoke test so SDK initialization contract changes are caught by tests rather than only after publishing.

The same adapter was also verified against Pi SDK 0.86.0 in an isolated worktree.

Fixes #360

Testing

  • pnpm typecheck
  • pnpm exec tsx --test src/local-agent-pi.test.ts
  • pnpm test
  • pnpm build
  • live devspace agents run pi validation through the default sandboxed path

Summary by CodeRabbit

  • Bug Fixes
    • Updated the Pi agent integration to use the current model runtime APIs, improving compatibility with the latest Pi coding agent version.
    • Model selection and authentication continue to work through the updated runtime handling.
  • Tests
    • Expanded coverage for model resolution, missing-model scenarios, runtime initialization, cleanup, and temporary configuration handling.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 31dd3307-120b-4bc3-bc5f-b3ef1d2fbe0a

📥 Commits

Reviewing files that changed from the base of the PR and between 531d3f9 and 981866b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • package.json
  • src/local-agent-pi.test.ts
  • src/local-agent-pi.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The Pi integration now targets SDK 0.80.10 and uses ModelRuntime for authentication, model storage, provider environment overrides, and model lookup. Tests update their mocks and add a default-driver runtime smoke test.

Changes

Pi runtime migration

Layer / File(s) Summary
Runtime construction and session wiring
package.json, src/local-agent-pi.ts
The SDK requirement is pinned to 0.80.10. The session factory creates ModelRuntime, applies provider environment overrides, and passes it to createAgentSession.
Session model resolution
src/local-agent-pi.ts
PiSessionLike, override handling, and model resolution now use modelRuntime.getAuth, getModel, and getModels.
Runtime test coverage
src/local-agent-pi.test.ts
Tests mock the ModelRuntime API and verify default runtime creation, closure, environment restoration, and temporary-directory cleanup.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant defaultPiSessionFactory
  participant ModelRuntime
  participant resolvePiModel
  participant createAgentSession
  defaultPiSessionFactory->>ModelRuntime: create runtime from auth.json and models.json
  defaultPiSessionFactory->>ModelRuntime: merge provider environment through getAuth
  defaultPiSessionFactory->>resolvePiModel: resolve configured model
  resolvePiModel->>ModelRuntime: call getModel or getModels
  defaultPiSessionFactory->>createAgentSession: pass modelRuntime
Loading

Suggested reviewers: waishnav

Merge Risk: ⚪ Minimal · up to 98186

The Pi adapter now uses the replacement runtime API and pins the compatible SDK version; no actionable merge-blocking risk remains identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: restoring Pi subagent compatibility after the SDK API migration.
Linked Issues check ✅ Passed The pull request satisfies the coding requirements in [#360]. src/local-agent-pi.ts uses ModelRuntime.create({ authPath, modelsPath }), passes modelRuntime to createAgentSession, and resolves …
Out of Scope Changes check ✅ Passed The reviewed changes stay within [#360]. The source changes migrate the Pi adapter to the replacement SDK API. The test changes verify model-runtime behavior and default SDK initialization. The exact …
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit hops through runtime doors,
With models neatly stored in drawers.
Auth winds weave through getAuth bright,
Smoke tests guard the path tonight,
And Pi now starts its session right.

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

Safe to merge; no blocking issues were found.

What we checked:

  • Authored the authentication compatibility check script and captured its source and the check's setup to verify shape before execution. T-Rex
  • Executed the compatibility check before and after, then ran the local PI tests to exercise the private-helper integration seam and verify environment precedence. T-Rex
  • Observed that both comparison runs exited cleanly (exit code 0) and concluded that keeping a P2 behavior finding is not supported, with a suggestion to add a regression test if coverage requires it. T-Rex

Summary

  • Pins the embedded Pi SDK to version 0.80.10 and migrates the Pi adapter to ModelRuntime.
  • Passes the runtime through session creation and resolves models through the updated SDK API.
  • Preserves configured provider environment values when resolving Pi authentication.

The authentication compatibility behavior works for both supported lookup forms, and the existing adapter smoke test continues to pass.

Reviews (1) · Last reviewed commit: "fix(pi): restore subagent compatibility"

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.

pi subagent fails with TypeError on a fresh npm install (^0.80.3 resolves to 0.80.10, which dropped the AuthStorage export)

1 participant