[PR #1317] [CLOSED] Support prompt references (@file.txt and $ls src) for modes and agents #9891

Closed
opened 2026-02-16 18:14:20 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1317
Author: @mpazik
Created: 7/25/2025
Status: Closed

Base: devHead: support-references-in-prompts


📝 Commits (1)

  • 9fc3d12 feat: support prompt references for modes and agents

📊 Changes

8 files changed (+170 additions, -4 deletions)

View changed files

📝 packages/opencode/src/agent/agent.ts (+10 -0)
📝 packages/opencode/src/cli/error.ts (+4 -0)
📝 packages/opencode/src/config/config.ts (+8 -0)
📝 packages/opencode/src/session/index.ts (+6 -3)
📝 packages/opencode/src/session/mode.ts (+11 -0)
packages/opencode/src/session/prompt-resolve.ts (+0 -0)
📝 packages/opencode/src/session/system.ts (+130 -0)
📝 packages/opencode/src/tool/task.ts (+1 -1)

📄 Description

Support for file references @file.txt and bash execution $`bash command` in agent markdown and mode configuration.

These features allow more complex context loading.

More about the feature on anthropic docs

https://docs.anthropic.com/en/docs/claude-code/common-workflows#reference-files-and-directories
https://docs.anthropic.com/en/docs/claude-code/slash-commands#bash-command-execution

Implementation details

  • Lazy execution when mode and agent are invoked
  • Support nested include
  • Break on circular dependencies
  • Limit of 50000 tokens
  • Custom error when prompt resoultion failed

Missing

Notes

  • I had trouble providing a base directory for relative paths. My solution is not perfect as the path is included in the config schema, so users could possibly override it. An alternative was to have ConfigPriv with this extra path, but that would be overkill just for this single use case.
  • Not a big fan of the prompt resolution place. Ideally, it would be resolved for both modes and agents inside the session/index.ts, but we don't pass the agent. Possible solutions:
    • Specialized chat for mode and chat for agent variant of the chat method
    • Mode and agent unified so we don't need to pass both of them
  • Would be great to opt out from await SystemPrompt.custom() as sometimes it provides redundant or misleading information (I have agents that get custom dir structure)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1317 **Author:** [@mpazik](https://github.com/mpazik) **Created:** 7/25/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `support-references-in-prompts` --- ### 📝 Commits (1) - [`9fc3d12`](https://github.com/anomalyco/opencode/commit/9fc3d12d13df6a61401ebd7e73b575b15ad552dc) feat: support prompt references for modes and agents ### 📊 Changes **8 files changed** (+170 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/agent/agent.ts` (+10 -0) 📝 `packages/opencode/src/cli/error.ts` (+4 -0) 📝 `packages/opencode/src/config/config.ts` (+8 -0) 📝 `packages/opencode/src/session/index.ts` (+6 -3) 📝 `packages/opencode/src/session/mode.ts` (+11 -0) ➕ `packages/opencode/src/session/prompt-resolve.ts` (+0 -0) 📝 `packages/opencode/src/session/system.ts` (+130 -0) 📝 `packages/opencode/src/tool/task.ts` (+1 -1) </details> ### 📄 Description Support for file references `@file.txt` and bash execution ``$`bash command` `` in agent markdown and mode configuration. These features allow more complex context loading. ## More about the feature on anthropic docs https://docs.anthropic.com/en/docs/claude-code/common-workflows#reference-files-and-directories https://docs.anthropic.com/en/docs/claude-code/slash-commands#bash-command-execution ## Implementation details - Lazy execution when mode and agent are invoked - Support nested include - Break on circular dependencies - Limit of 50000 tokens - Custom error when prompt resoultion failed ## Missing - Documentation - added when - Integration with https://github.com/sst/opencode/pull/1303 (easy) ## Notes - I had trouble providing a base directory for relative paths. My solution is not perfect as the path is included in the config schema, so users could possibly override it. An alternative was to have ConfigPriv with this extra path, but that would be overkill just for this single use case. - Not a big fan of the prompt resolution place. Ideally, it would be resolved for both modes and agents inside the `session/index.ts`, but we don't pass the agent. Possible solutions: - Specialized chat for mode and chat for agent variant of the chat method - Mode and agent unified so we don't need to pass both of them - Would be great to opt out from `await SystemPrompt.custom()` as sometimes it provides redundant or misleading information (I have agents that get custom dir structure) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:20 -05:00
yindo closed this issue 2026-02-16 18:14:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9891