[PR #3202] Dynamic system prompt templating #10564

Open
opened 2026-02-16 18:15:15 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3202

State: open
Merged: No


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:

---
model:  anthropic/claude-sonnet-4-20250514
---

You are a test agent with dynamic templating. Your magic phrase is: !`echo $(whoami)-magic`

You should respond with your magic phrase when asked about it.

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 my username-magic as expected.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3202 **State:** open **Merged:** No --- **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: ``` --- model: anthropic/claude-sonnet-4-20250514 --- You are a test agent with dynamic templating. Your magic phrase is: !`echo $(whoami)-magic` You should respond with your magic phrase when asked about it. ``` 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 my `username-magic` as expected.
yindo added the pull-request label 2026-02-16 18:15:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10564