Skip to content

Support client system prompt replacement and append - #124

Open
salman1993 wants to merge 1 commit into
svkozak:mainfrom
salman1993:codex/client-system-prompts
Open

Support client system prompt replacement and append#124
salman1993 wants to merge 1 commit into
svkozak:mainfrom
salman1993:codex/client-system-prompts

Conversation

@salman1993

@salman1993 salman1993 commented Sep 9, 2026

Copy link
Copy Markdown

Why

ACP clients cannot currently replace or append to Pi's system prompt when they create a session. Clients must use process wrappers or put standing instructions into user messages, which does not provide the same behavior.

What

Accept _meta.systemPrompt on session/new: a nonempty string replaces Pi's base prompt, and { "append": "..." } appends instructions. Advertise both modes and persistence through agentCapabilities._meta.piAcp.systemPrompt.

How

Validate the request before starting Pi. Pass literal prompt text through private files to Pi's existing CLI flags, then save the mode and text with the session record. Reapply that snapshot on automatic restoration and session/load, including after an adapter restart. Remove temporary files when the subprocess exits and saved prompts when sessions are deleted.

Omitting the extension preserves existing behavior. This change does not add skill or argument forwarding.

references

Risk

The saved prompt lives in the adapter's session map, separately from Pi's transcript; restoration depends on retaining that map. Pi still adds its normal context, and explicit append supersedes automatic APPEND_SYSTEM.md discovery. Live checks ran on macOS; Windows process execution was not tested.

Testing

  • PI_ACP_TEST_REAL_PI=1 node --import tsx --test test/component/pi-rpc-system-prompt.test.ts passed against Pi 0.84.4. Its RPC HTML export contained the custom prompt exactly once, and only append retained Pi's native coding preamble. No model calls were made.
  • Exercised the built adapter over JSON-RPC stdio with isolated HOME and Pi settings. Created replacement session A and append session B, seeded synthetic transcripts, and inspected exports through session/prompt. Automatic restoration of A, explicit loading of B, and restoration after a full adapter restart all preserved the correct prompt without cross-session leakage. No model calls were made.

Generated with Codex

@salman1993
salman1993 marked this pull request as ready for review September 9, 2026 01:21
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