Repository navigation
Keep later prompt sections when adding memory, agents and styles - #407
Merged
Merged
Conversation
The subagent roster, the memory index and the active output style were added by returning a whole systemPrompt from before_agent_start. pi treats a returned prompt as fixed text, so sections that extensions loaded afterwards add to the prompt options never reached the model. pi's MCP extension loads after pi-code and lists servers with deferred or codemode tools in an mcp_servers section, which was dropped on every turn a subagent was discoverable. The three handlers now edit the prompt options instead: the roster and the memory index become the subagents and memory sections, a style that keeps the coding instructions becomes the output_style section, and a style that replaces them sets customPrompt, which replaces the same preamble, tools, rules and docs sections applyStyle cut. Where pi does not re-render the prompt from its options, or an earlier handler forced a prompt, they return the appended systemPrompt as before.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The subagent roster, the memory index and the active output style were added by returning a whole
systemPromptfrombefore_agent_start. pi treats a returned prompt as fixed text, so sections that extensions loaded afterwards add to the prompt options never reached the model. pi's MCP extension loads after pi-code and lists servers whose tools are deferred or codemode in anmcp_serverssection; with a discoverable subagent (the built-in agents count) that section was dropped from every request.extensions/internal/prompt-options.ts): the roster and the memory index become thesubagentsandmemorysections. A style that keeps the coding instructions becomes theoutput_stylesection, and one that replaces them setscustomPrompt, which replaces the same preamble, tools, rules and docs sectionsapplyStylecut.<subagents>,<memory>and<output_style>blocks instead of## Subagents,## Memoryand## Output Styleheadings appended at the end.systemPromptas before and leave the options as found.Tests run the handlers through pi's own
buildSystemPromptfollowed by a handler that addsmcp_servers, and assert both reach the final prompt. Measured with real pi 1.2.0 and all pi-code extensions plus a deferred server in pi'smcp.json: onmainthe request carried nomcp_serverssection; with this change it lists the server.Needed for #406, where pi-code's own servers become deferred.
npm run checkpasses (Biome, strict tsc, Vitest)