Skip to content

feat(pi): add plan mode - #6372

Merged
BillLeoutsakosvl346 merged 9 commits into
stagingfrom
feature/pi-plan-mode
Aug 9, 2026
Merged

feat(pi): add plan mode#6372
BillLeoutsakosvl346 merged 9 commits into
stagingfrom
feature/pi-plan-mode

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • add a BYOK-only Plan mode that explores a disposable GitHub checkout in the existing Pi sandbox
  • remove the authenticated remote before Pi starts and provide no commit, push, PR, review, or GitHub-write finalization
  • reuse existing skills, memory, streaming, redaction, cancellation, and optional sandbox search extension
  • expose only the inputs and outputs needed for planning

Validation

  • PI executor and block/model/key-condition suites: 25 files, 464 passed, 1 skipped
  • Sim type-check
  • repository format and lint checks
  • check:import-specifiers
  • check:boundaries
  • check:audits (22 audits)

Stack

This PR is intentionally based on refactor/pi-mode-folders (PR #6362). After #6362 merges, this branch will be rebased onto current staging, the PR will be retargeted to staging, and the full validation and bot-review cycle will be repeated.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 9, 2026 1:47am

Request Review

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces a new sandbox execution path with GitHub clone credentials and BYOK model keys in the remote environment; mitigations (remote removal, redaction, no finalize) are explicit but the surface area is security-sensitive.

Overview
Adds a Plan mode (cloud_plan) to the Pi Coding Agent: explore a GitHub repo in the existing E2B sandbox and return an implementation plan without commit, push, PR, or other GitHub writes.

The block UI exposes Plan alongside other modes, limits visible inputs to repo/task/model/BYOK/search/skills/memory, and hides PR/diff/branch outputs. Plan is treated like Create PR and Update PR for API keys (always BYOK in the sandbox) and extends copilot credential validation accordingly.

Execution clones the selected base branch, removes origin so the agent cannot push, runs Pi with planning guidance and optional sandbox search, and uses finalizePhases: 0 so sandbox timeouts do not reserve commit/push time. Event filtering and agent_end handling now carry final assistant text so Plan can replace streamed progress with the authoritative Markdown plan when streaming.

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

@gitguardian

gitguardian Bot commented Aug 7, 2026

Copy link
Copy Markdown

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a BYOK-only Plan mode that runs Pi against a disposable GitHub checkout and returns a planning document without a GitHub write/finalization phase.

  • Adds Plan-mode block inputs, output visibility, model-key handling, routing, and tests.
  • Introduces an ephemeral sandbox backend that clones the selected branch, removes the authenticated remote, runs Pi, and redacts streamed output.
  • Extends event normalization to expose the canonical final assistant response.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/pi/cloud/plan/backend.ts Implements the disposable Plan-mode clone, credential scoping, Pi execution, event handling, redaction, cancellation, and cleanup flow.
apps/sim/executor/handlers/pi/pi-handler.ts Routes cloud_plan executions, supplies contextual inputs, emits only the canonical final plan in streaming mode, and omits change-oriented outputs.
apps/sim/blocks/blocks/pi.ts Exposes Plan mode with its required sandbox inputs, BYOK behavior, contextual options, and Plan-appropriate outputs.
apps/sim/executor/handlers/pi/core/events.ts Extracts text blocks from the final assistant message into a canonical final event.
apps/sim/providers/pi-providers.ts Classifies Plan alongside other sandbox modes that require user-provided model credentials.

Sequence Diagram

sequenceDiagram
  participant Workflow
  participant Handler as Pi Handler
  participant Sandbox
  participant GitHub
  participant Pi

  Workflow->>Handler: Execute cloud_plan
  Handler->>Handler: Resolve BYOK key, skills, memory
  Handler->>Sandbox: Create disposable sandbox
  Sandbox->>GitHub: Clone selected/default branch
  Sandbox->>Sandbox: Detach checkout and remove origin
  Handler->>Sandbox: Write scrubbed prompt
  Sandbox->>Pi: Run with model/search credentials
  Pi-->>Handler: Progress and final events
  Handler-->>Workflow: Final Markdown plan and usage
  Sandbox-->>Handler: Dispose sandbox
Loading

Reviews (5): Last reviewed commit: "fix(pi): stream only final plan content" | Re-trigger Greptile

Comment thread apps/sim/executor/handlers/pi/cloud/plan/backend.ts
Comment thread apps/sim/executor/handlers/pi/cloud/plan/backend.ts Outdated
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 07949ce. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/executor/handlers/pi/cloud/plan/backend.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2b653a6. Configure here.

# Conflicts:
#	apps/sim/executor/handlers/pi/cloud/authoring/backend.ts
#	apps/sim/executor/handlers/pi/cloud/babysit/round.ts
#	apps/sim/executor/handlers/pi/cloud/review/backend.ts
#	apps/sim/executor/handlers/pi/core/redaction.ts
#	apps/sim/executor/handlers/pi/local/backend.test.ts
#	apps/sim/executor/handlers/pi/local/backend.ts
#	apps/sim/executor/handlers/pi/pi-handler.test.ts
#	apps/sim/executor/handlers/pi/pi-handler.ts
@BillLeoutsakosvl346
BillLeoutsakosvl346 requested a review from a team as a code owner August 8, 2026 23:07
@BillLeoutsakosvl346
BillLeoutsakosvl346 changed the base branch from refactor/pi-mode-folders to staging August 8, 2026 23:08
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Demo:

Screen.Recording.2026-08-08.at.6.59.17.PM.mp4

@BillLeoutsakosvl346
BillLeoutsakosvl346 merged commit d382761 into staging Aug 9, 2026
29 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