Skip to content

feat(server): add Pi Agent provider - #9648

Closed
NachikethReddyY wants to merge 3 commits into
pingdotgg:mainfrom
NachikethReddyY:feat/pi-agent-provider
Closed

feat(server): add Pi Agent provider#9648
NachikethReddyY wants to merge 3 commits into
pingdotgg:mainfrom
NachikethReddyY:feat/pi-agent-provider

Conversation

@NachikethReddyY

@NachikethReddyY NachikethReddyY commented Sep 4, 2026

Copy link
Copy Markdown

What Changed

  • Added an Early Access piAgent provider using Pi’s official RPC mode.
  • Added dynamic model and thinking-level discovery, streaming, tool activity, steering, interruption, compaction, and session resume.
  • Preserved Pi extensions, packages, skills, prompts, custom providers, profiles, credentials, and sessions by launching the installed Pi binary.
  • Added Pi usage and cost reporting from Pi’s session files.
  • Added $ skill discovery and RPC-native extension dialogs across web and mobile.
  • Exposed only Full Access because narrower permission modes cannot currently be enforced through Pi RPC.

Intentional limitations

  • TUI-only ctx.ui.custom widgets cannot render over RPC.
  • Generic extension tools show their title and lifecycle status, but raw arguments and returned details are not currently projected into the final card.
  • Pi emits command-output deltas, but T3 does not currently project them into the client card.
  • Non-Git projects and files written outside the selected worktree do not appear in the changed-files card.
  • Generic ACP Registry support remains separate future work.

Why

T3 Code already included a disabled Pi Agent entry, but users could not run their existing Pi installations through T3. Using Pi’s official RPC mode keeps the integration at the provider boundary and preserves the user’s existing Pi configuration without embedding the Pi SDK into the server.

The integration was exercised with real Pi models, custom skills, custom tools, web search, interruption, compaction, session resume, project generation, and usage reconciliation.

Review fixes

The first review round identified lifecycle and state-reconciliation edge cases. The follow-up commit:

  • keeps an interrupted Pi turn active until Pi emits its authoritative settlement, preventing late events from completing a retry turn;
  • serializes duplicate interrupts and cleans up startup, shutdown, stale-transport, and per-thread-lock state;
  • reconciles unsupported draft and thread runtime modes to Full Access on web, mobile, queued sends, and the server boundary;
  • accepts dotted, Unicode, numeric-leading, and punctuation-delimited discovered skill names; and
  • propagates Pi catalog transport failures so a dead RPC process cannot be reported as ready.

A second review follow-up removes the shadowed abort arm, validates malformed Pi model state, keeps retained tool output bounded after truncation, makes the exit fixture flush reliably, and keeps an explicit empty runtime-capability fallback visible.

Post-rebase verification: 228 focused tests passed across Pi RPC, adapter, provider, skill dispatch, orchestration, shared runtime, web/mobile model state, and mobile outbox behavior. Targeted server, web, mobile, and client-runtime typechecks passed. An isolated browser pass confirmed that switching a Codex draft from Auto to Pi immediately reconciles it to Full access and leaves Full access as the only runtime choice.

UI Changes

Before, Pi Agent was unavailable as a usable provider. After this change, users can configure Pi Agent, select dynamically discovered models and thinking levels, invoke Pi skills with $, inspect tool activity, and view Pi usage.

Open screenshots and recordings

Provider models and reasoning controls

Pi model and reasoning controls

Pi Agent provider and model surface

Pi Agent models

Completed Pi/Sol project-generation turn

Completed Pi Sol turn

Progress narration and configured web search

Pi progress and web search

Usage provider and model breakdown

Pi usage breakdown

Usage with Terra and Luna sessions

Pi Terra and Luna usage

Manual skills discovered through $

Pi skills picker

Completed custom-skill audit

Completed Pi custom skill

Pi/Sol web-search test — 5× speed

browser-recording-mtmrh0o3-5x.mp4

Pi Tool Lab interaction

browser-recording-mtmrrv7c.webm

Fishslop gameplay and restart

browser-recording-mtmrwn0z.webm

Custom ask_user fallback and resumed turn

browser-recording-mtmsbyqm.webm

Native manual-skill dispatch

browser-recording-mtmtp4ec.webm

$html-communicator audit — 5× speed

browser-recording-mtmuakkn-5x.webm

Changed-files card — 5× speed

browser-recording-mtmujkay-5x.webm

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Generated by GPT-5.6 Sol through the Codex harness.


Note

High Risk
Introduces a large new provider driver/RPC path and changes orchestration turn-start/runtime-mode ordering; Pi is limited to full-access at the adapter boundary, but incorrect reconciliation could still send wrong modes to other providers.

Overview
Adds an Early Access Pi Agent provider that talks to a user-managed Pi binary over official RPC, including catalog discovery, session resume, streaming turns, steering/interrupts, extension UI dialogs, and composer $skill/skill:name dispatch.

Runtime mode is now reconciled against each provider’s supportedRuntimeModes on mobile (new-task flow, thread composer, settings sheet, outbox drain, and turn start) and at dispatch; the thread settings UI only offers filtered runtime choices. The orchestration decider persists a reconciled runtimeMode via thread.runtime-mode.set before thread.turn.start when it differs from the thread snapshot, and turn-start events use the command’s mode instead of the stale thread value.

Mobile also gains a Pi Agent icon, usage chart series for pi, and model options that carry provider runtime capabilities. Codex model picker labels re-attach reasoning effort from slugs when the backend strips it from display names.

Reviewed by Cursor Bugbot for commit ac926b3. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add PiAgentDriver and provider integration across web and mobile

  • Adds PiAgentDriver, PiAgentAdapter, and PiAgentProvider to manage Pi RPC sessions, catalog discovery, and status checks. Pi Agent is disabled by default.
  • Adds PiSettings to server contracts, including binary path, agent directory, and session directory configuration.
  • Implements Pi usage parsing and tracking in usageTranscripts.ts and UsageService.ts, adding the pi provider kind to the usage contract.
  • Adds provider-level supported-runtime-modes to ServerProvider and introduces runtime-mode reconciliation across mobile, web, and server to filter unsupported modes and replace them with the safest supported mode.
  • Risk: fallbackTextGenerationProvider in serverSettings.ts skips Pi Agent, so enabling Pi Agent alone no longer selects it as the text-generation fallback. Runtime-mode reconciliation writes corrected modes back to existing composer drafts.

Macroscope summarized ac926b3.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Sep 4, 2026
Comment thread apps/server/src/provider/Layers/PiAgentAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAgentAdapter.ts
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/server/src/provider/Layers/PiAgentAdapter.ts Outdated
Comment thread apps/server/src/provider/Drivers/PiSkillDispatch.ts Outdated
Comment thread apps/server/src/provider/Layers/PiAgentProvider.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces a large, cross-cutting Pi Agent capability with new production RPC/session behavior, runtime-mode reconciliation, usage metering, and user-facing web/mobile changes. It also changes product defaults and adds static-analysis diagnostic suppressions, so the scope and policy requirements call for human review.

You can add or adjust custom eligibility rules. Learn more.

@NachikethReddyY

Copy link
Copy Markdown
Author

Confirmed the actionable review findings on commit 8d40233:

  • keep an interrupted Pi turn active until Pi emits agent_settled, so a late settle cannot complete a follow-up turn;
  • reconcile unsupported runtime modes when switching providers, using the staged model/provider on web and mobile;
  • release per-thread adapter locks safely after the final operation on a stopped session;
  • accept dotted skill names and punctuation-delimited $skill mentions;
  • propagate Pi catalog RPC transport failures instead of advertising a dead process as ready.

I will add focused regression coverage for each change. I also checked the filtered relative-directory documentation finding: the driver already resolves configured relative Pi paths against the server working directory before creating sessions, and its focused test covers that invariant.

Generated by GPT-5.6 Sol through the Codex harness.

Generated by GPT-5.6 Sol through the Codex harness.
Address review findings around interruption settlement, runtime-mode reconciliation, lock cleanup, skill parsing, and catalog discovery failures. Add focused regressions across server, web, mobile, and shared runtime paths.\n\nGenerated by GPT-5.6 Sol through the Codex harness.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e316d64. Configure here.

Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts Outdated
Remove the shadowed abort branch, validate RPC model state, keep cumulative tool output bounded, align empty runtime capabilities with their fallback, and make the process-exit fixture flush reliably.\n\nGenerated by GPT-5.6 Sol through the Codex harness.
@NachikethReddyY

Copy link
Copy Markdown
Author

Follow-up review fixes are pushed in ac926b3: the shadowed abort arm is removed; explicit empty runtime capabilities retain a visible supervised fallback; malformed Pi model state returns the existing validation error; cumulative tool output remains bounded after truncation; and the process-exit fixture flushes its response before exiting. The relative-directory documentation needs no change: PiAgentDriver resolves configured paths against ServerConfig.cwd before constructing the adapter, covered by PiAgentDriver.test.ts.

Focused follow-up verification: 91 tests and targeted server, mobile, and client-runtime typechecks passed.

Generated by GPT-5.6 Sol through the Codex harness.

@juliusmarminge

Copy link
Copy Markdown
Member

Closing as part of the open-PR backlog sweep (wave 2).

Reason: Duplicate Pi provider rebuild of open #7211/#10474
Related: #7211

Reopen if this is still wanted and you’re willing to rebase onto current main.

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

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants