forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 3
fix: skip system prompt for claude #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
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
…3.4 -> 1.3.6 and fix type errs (anomalyco#8499) Co-authored-by: Github Action <[email protected]>
Signed-off-by: sami <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
Collaborator
Author
|
nevermind, dario just hates opencode. remove opencode references from system prompts and it works |
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.
Summary
Greptile Summary
This PR prevents system prompt duplication for Claude models accessed via the Anthropic provider. Previously, Claude models would receive the system prompt both through the standard system message mechanism and via the
options.instructionsfield, causing prompt injection issues.Key Changes:
SystemPrompt.provider()to return an empty array for Claude models via Anthropic provider (checking bothproviderID.includes("anthropic")andapi.id.includes("claude"))llm.tsto move provider/auth lookups earlier in the flow and conditionally skipSystemPrompt.provider()for Codex sessionsoptions.instructions(for Codex) or not at all (letting the native provider handle it)Additional Improvements:
prompt.tswhen transitioning from plan to build modeanthropicModelparameter from GitLab providerProvider.list()Confidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant LLM participant SystemPrompt participant Provider participant API Client->>LLM: stream(input) Note over LLM: Fetch provider and auth info early LLM->>Provider: getProvider and getLanguage Provider-->>LLM: provider and language info Note over LLM: Determine if Codex session LLM->>SystemPrompt: header(providerID) SystemPrompt-->>LLM: header array alt Has agent prompt Note over LLM: Use agent prompt else isCodex Note over LLM: Skip SystemPrompt.provider() else Regular session LLM->>SystemPrompt: provider(model) alt Anthropic with Claude SystemPrompt-->>LLM: empty array (prevents duplicate) else Other providers SystemPrompt-->>LLM: provider prompt end end alt isCodex Note over LLM: Set options.instructions<br/>Wrap system as user message else Anthropic (non-Codex) Note over LLM: Send as system role end LLM->>API: Send request with appropriate format API-->>LLM: Stream response LLM-->>Client: StreamTextResult