feat(opencode): support custom system prompt per model#18178
Open
mjdouglas wants to merge 2 commits intoanomalyco:devfrom
Open
feat(opencode): support custom system prompt per model#18178mjdouglas wants to merge 2 commits intoanomalyco:devfrom
mjdouglas wants to merge 2 commits intoanomalyco:devfrom
Conversation
52b4772 to
a541197
Compare
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
ae053c9 to
afa062d
Compare
Allow custom models to define their own system prompt via the `prompt` field in provider model config, overriding the default model-family matching logic in SystemPrompt.provider(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
afa062d to
13e1f33
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #18177
Type of change
What does this PR do?
Custom models configured in
opencode.jsonfall back to a generic system prompt becauseSystemPrompt.provider()only matches known model families (claude, gemini, gpt, etc.). The agent-levelpromptfield doesn't solve this because agents and models are orthogonal — a model may need specific instructions regardless of which agent uses it.This adds a
promptfield to the model config. When set, it's used as the system prompt instead of the default model-family matching. Supports inline strings or file references via the existing{file:path}config substitution:{ "provider": { "my-provider": { "models": { "my-model": { "prompt": "You are a custom coding assistant." } } } } }{ "provider": { "my-provider": { "models": { "my-model": { "prompt": "{file:./prompts/my-model.md}" } } } } }How did you verify your code works?
bun test test/session/system.test.ts test/provider/provider.test.ts— 79 tests pass, covering inline prompts, priority over model ID matching, fallback behavior, and config plumbing.Screenshots / recordings
Not a UI change.
Checklist