Skip to content

fix(pi): keep runtime context at system boundary - #1002

Open
Tarun-joy wants to merge 2 commits into
mksglu:mainfrom
Tarun-joy:fix/pi-hidden-context
Open

fix(pi): keep runtime context at system boundary#1002
Tarun-joy wants to merge 2 commits into
mksglu:mainfrom
Tarun-joy:fix/pi-hidden-context

Conversation

@Tarun-joy

@Tarun-joy Tarun-joy commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • inject Pi runtime routing, active memory, and resume context through before_agent_start.systemPrompt
  • keep automation at Pi's host-owned model-only boundary
  • remove the custom/user message injection path so runtime instructions cannot appear as user-authored chat

Why

Pi's display: false only controls the interactive transcript. API consumers and adapters may still reinterpret custom messages as user messages. Runtime automation is system-owned context, so it belongs in the system prompt rather than in conversation history.

This intentionally favors transcript correctness and stable role semantics over the previous prompt-cache optimization.

Validation

  • npx vitest run tests/pi-extension.test.ts — 68 passed
  • focused Resume/Routing tests — 7 passed
  • tests assert no context handler is registered
  • clean scoped diff

@Tarun-joy Tarun-joy changed the title fix(pi): hide runtime context from chat fix(pi): keep runtime context at system boundary Jul 27, 2026
@Tarun-joy

Copy link
Copy Markdown
Author

Review verdict: APPROVE

The revised implementation uses Pi's canonical before_agent_start system-prompt result instead of relying on display: false for role correctness. This keeps context model-visible, prevents API/adapters from reclassifying automation as user chat, preserves the existing prompt prefix, and removes pending-message state plus the one-shot context hook.

Validated with the complete Pi adapter suite (68/68), focused Resume/Routing coverage (7/7), typecheck/build and bundle drift checks. The branch is clean, scoped to the Pi adapter and tests, current with upstream main, and mergeable. No blockers found.

@Tarun-joy
Tarun-joy force-pushed the fix/pi-hidden-context branch from cb25e81 to 4a6328a Compare July 30, 2026 01:52
@Tarun-joy

Copy link
Copy Markdown
Author

Revalidated after rebasing onto current upstream main (da14dc1).

  • Pi adapter suite: 68/68 passed
  • Typecheck: passed
  • Build + bundle integrity + asymmetric drift: passed
  • Branch: clean and MERGEABLE / CLEAN
  • Overlap rechecked: Hide Pi context injection from user entry #864 still uses hidden custom messages, which Pi/API adapters can reclassify as user-role content; this PR keeps runtime automation at the canonical system boundary instead.

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