Assistant: Add prompt rendering mechanism #9993
Draft
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.
This PR has three main aims:
Rework how our internal prompts are built, introducing templating and allowing us to move logic from the extension's
.ts
source into.md
files.Create a way for developers to enable and disable parts of Assistant's prompts at runtime, to assist with testing and QA.
Replace our
llms.txt
implementation and instead integrate Assistant with Code OSS's notion of prompt files, custom instructions, modes, & commands. (See here for details).Also included are some general fixes to prompting and tool calls, including the changes in #9991 and #9974. I will rebase those specific changes away from this branch as they hit
main
.Internal prompt files
Assistant's prompt files may now have a yaml header with a
mode
property indicating in which modes the prompt should be included. Prompts are concatenated in the order defined by theorder
yaml property.Templating is done using Squirrely, and this allows us to move some of the branching logic (e.g. different wording in the "inline editor", or when streaming edits is enabled) into the prompt files. This is the same template engine Databot currently uses, aligning us there.
The default prompt file has been split into different sections, reflecting the purpose of each section.
Prompts for commands have the
command
property, and also amode
property, defining the slash command and for which modes the command is active. A command's prompt document(s) is appended to the system prompt for the currently active mode.Developer prompt management
A new command has been added, gated by
isDevelopment
(Q: What is this value in daily builds?). When enabled, the command allows a user to turn on and off parts of the Assistant system prompts.This allows for a quick way to test the effect of individual prompt sections, and even return to the stock model if required:
It might be nice if this was on for daily builds, but should definitely be off on release builds.
Note: Positron context info is still added even if all prompts are off. We can add an extra line in this manager to disable it if we think it would be useful.
LLM instructions
Our special handling for
llms.txt
has been removed. With this PR it is added to requests using a different mechanism (next section).Custom prompt files
Upstream Code OSS has support for custom instructions, commands and chat modes. This PR makes this all work better with Positron. It also adds our own directories for the custom files, under
.positron
, to separate from the GitHub Copilot Chat naming.Here are some examples:
Custom Command
Use the cog icon in Assistant, select Prompt Files, then create a new prompt file in the
.positron/prompts
folder.Here is an example defining a custom
/spelling
command, saved as `./positron/prompts/spelling.prompt.mdThis should then be available as a command in the given chat mode:
Custom Chat Mode
Example:
.positron/chatmodes/pirate.chatmode.md
:Custom instructions
This already works as expected, in that
AGENTS.md
is loaded automatically into the context if it exists in the root of the project.This PR tweaks the upstream mechanism to also include any of:
Project tree tool
I have simplified the project tree tool a lot. I found in testing the model often struggles to infer paths from the previous array-based output format. The tool now outputs paths as a newline separated list:
If the number of entries is too long, the list will be limited by removing the longest paths first.
Still TODO