[PR #3197] feat: add dynamic TypeScript system prompts for custom agents #10562

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

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

State: closed
Merged: No


Adding dynamic system prompt capability by passing a typescript or javascript file for agent prompt.

NOTE: This entire PR was created by opencode, just a code reference for #3195 - no need to accept this as is if additional discussion is needed (also edits on this PR are enabled).

On quick review / glance, there's some questionable things imo like picking between input.system or input.agent.prompt for the prompt to resolve (I don't know if it just made up input.system).

The comment below is the commit message from opencode.


  • Add DynamicPrompt namespace with TypeScript/JavaScript execution capability
  • Support both named export (system) and default export functions
  • Pass rich context including provider, model, directory, git status to prompt functions
  • Update resolveSystemPrompt to handle dynamic prompt resolution
  • Maintain backward compatibility with static prompts and text file includes
  • Add graceful error handling with fallback to original prompts
  • Support .ts, .js, .mts, .mjs file extensions
  • Add comprehensive unit and integration tests

Resolves the need for dynamic system prompt generation without initial tool calls, enabling context-aware agents that can preload environment information.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3197 **State:** closed **Merged:** No --- Adding dynamic system prompt capability by passing a typescript or javascript file for agent prompt. NOTE: This entire PR was created by opencode, just a code reference for #3195 - no need to accept this as is if additional discussion is needed (also edits on this PR are enabled). On quick review / glance, there's some questionable things imo like picking between input.system or input.agent.prompt for the prompt to resolve (I don't know if it just made up input.system). The comment below is the commit message from opencode. --- - Add DynamicPrompt namespace with TypeScript/JavaScript execution capability - Support both named export (system) and default export functions - Pass rich context including provider, model, directory, git status to prompt functions - Update resolveSystemPrompt to handle dynamic prompt resolution - Maintain backward compatibility with static prompts and text file includes - Add graceful error handling with fallback to original prompts - Support .ts, .js, .mts, .mjs file extensions - Add comprehensive unit and integration tests Resolves the need for dynamic system prompt generation without initial tool calls, enabling context-aware agents that can preload environment information.
yindo added the pull-request label 2026-02-16 18:15:15 -05:00
yindo closed this issue 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#10562