Skip to content

feat(pi-extension): keep host system prompt parts separate - #243

Merged
SSHdotCodes merged 1 commit into
BetterWright:mainfrom
blyzer:feat/keep-system-prompt-parts
Nov 25, 2026
Merged

SSHdotCodes merged 1 commit into
BetterWright:mainfrom
blyzer:feat/keep-system-prompt-parts

Conversation

@blyzer

@blyzer blyzer commented Nov 24, 2026 •

Copy link
Copy Markdown

What and why

The native Pi extension's before_agent_start hook now appends its guardrail text as its own system prompt part when the host passes the prompt as an array. Before, it built ${String(event.systemPrompt)}\n\n...: for an array String() joins the parts with commas, so the host's parts were lost, and the host's own parts layout was not preserved. I did not measure any cache effect from this. A string prompt (older hosts) keeps the previous behaviour.

Checklist

  • bun run release:check passes locally. Not fully: under the pinned Bun 1.4.0, 1344 pass and 1 fails: unit runner executes TypeScript sources and ignores stale compiled files. It fails identically on the unmodified base on my machine and passes in CI. Under Bun 1.4.3 a second test, Bun 1.4 is the pinned project runtime, also fails (version pin). Everything else in the gate (versions, lint, typecheck, build, declarations, tarball) passed.
  • Locally launched browsers and Electron attachments stay on the guard proxy. Unrelated: no transport or launch code touched.
  • No secret value reaches the model sandbox. Unrelated: the only text added is the existing guardrail prompt.
  • Dependency pins are still mirrored everywhere. bun run check:versions is green.
  • Public API changes update types/*.d.ts. No public API change. bun run test:types and bun run check:package are green.
  • The two branch-protected CI job names are unchanged and no new action was added.
  • No unit test imports src/worker.ts or dist/src/worker.js.
  • User-visible behaviour is reflected in CHANGELOG.md.
  • Nothing private is being committed.

How it was verified

  • New test in tests/node/pi-extension.test.ts: "native Pi extension appends guardrails as a separate part when the host passes prompt parts". 14/14 pass in that file.
  • Negative control: with src/pi-extension.ts reverted to the base, that test fails (13 pass, 1 fail).
  • biome ci on the changed files and bun run typecheck pass.
  • CI on my fork's PR: all jobs green on ubuntu, macOS and Windows (Node 22 and 24), plus "Worker copies in sync", "Node tests" and the dependency audit.
  • Platform used locally: macOS, Bun 1.4.0 (pinned) and 1.4.3. I did not run the managed-browser suite (BETTERWRIGHT_REQUIRE_BROWSER=1) because the change does not touch browser code.

Behaviour change

String prompts are unchanged. Array prompts now get the guardrails as one extra trailing part. OMP's before_agent_start takes and returns systemPrompt: string[], so an extension should return parts, not one joined string.

Pi hosts pass the system prompt as an array of parts and place provider cache breakpoints between them. Joining the parts into one string moved the whole prompt whenever any part changed. Append the guardrail prompt as its own part for arrays and keep the joined string for string or missing prompts.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Automated E2E review: blocked (fork PR, no maintainer approval yet)

  • Head SHA: fff3dd9ecb4bc74f5bbbba560a50735c2a9dfc95, base 7aee003e7b627e292f852963b4ae40b569f41e21
  • This PR comes from the fork blyzer/betterwright, and the author has no repository association. The review policy needs a BetterWright maintainer to approve explicitly before any fork code runs.
  • Not run: build, typecheck, lint, unit tests, real Pi before_agent_start flow, recordings. No fix PRs opened.

Static read only. This is not E2E proof:

  • src/pi-extension.ts: an array systemPrompt now returns [...parts, guardrailPrompt] and leaves the input unchanged. The string and missing cases keep the old "<prompt>\n\n<guardrails>" join. An empty array becomes [guardrails]. I found no defect.
  • tests/node/pi-extension.test.ts: there are 2 blank lines after the new tests, where the file normally has 1. This is only a style nit.

To unblock the review, a maintainer can approve running this SHA in the Devin session, and the full E2E review will then run against it.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I haven't run anything for PR #243. It comes from the fork blyzer/betterwright, its author has no role in the repo, and no maintainer has approved running its code. I posted a comment on the PR explaining this.

That comment includes a static read of the diff at head fff3dd9, which found no defects. No build, tests, real Pi flow, recordings or fix PRs were done.

If you're a BetterWright maintainer, do you approve running this fork's code at fff3dd9 in this isolated VM?

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The Pi extension now keeps host prompt parts separate and appends its operating guidance as one trailing part.

  • Pi keeps host prompt parts separate and adds its guidance last.

blyzer acknowledged a release-check test failure and reported that it also occurs on the unmodified base.

Reviews (1) · Last reviewed commit: "feat(pi-extension): keep host system pro..." · Reviewed by Greptile

@SSHdotCodes
SSHdotCodes merged commit 28da406 into BetterWright:main Nov 25, 2026
10 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.

3 participants