Skip to content

feat: add dynamic TypeScript system prompts for custom agents - #3197

Closed
Flux159 wants to merge 1 commit into
anomalyco:devfrom
Flux159:dynamic-system-prompt
Closed

Flux159 wants to merge 1 commit into
anomalyco:devfrom
Flux159:dynamic-system-prompt

Conversation

@Flux159

@Flux159 Flux159 commented Oct 15, 2025

Copy link
Copy Markdown

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.

- 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.
@Flux159

Flux159 commented Oct 15, 2025

Copy link
Copy Markdown
Author

Closing since discussed in #3195 that it is probably better to support command bash syntax in agents markdown.

@Flux159 Flux159 closed this Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant