Dynamic system prompt templating #3202
Open
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.
Summary:
Adding the ability to parse markdown templating for agent system prompts. Specifically adds ability to parse
!
and@
references inside of agent prompts.This PR adds a helper util/template.ts that handles both bash & file reference templates, then uses this inside of session/prompt.ts. The rest is just automated testing for the functionality.
This is specifically for #3195
Test plan:
Manually tested by making a custom agent inside of
.opencode/agent/test.md
with the following contents:Then opening opencode dev mode:
bun dev
, switching to the test agent via/agents
, then asking "What is your magic phrase" and it responded with myusername-magic
as expected.