fix(query): honour clientContext when codeSystemPrompt=false#526
Open
ilie-neacsu wants to merge 1 commit into
Open
fix(query): honour clientContext when codeSystemPrompt=false#526ilie-neacsu wants to merge 1 commit into
ilie-neacsu wants to merge 1 commit into
Conversation
resolveSystemPrompt() was returning { systemPrompt: '' } unconditionally
when codeSystemPrompt === false, discarding the client's system prompt
before it could be used.
Fix: return { systemPrompt: clientContext ?? '' } so the client system
prompt passes through when present, while still forcing an empty string
(not undefined) when absent — preserving the defensive preset-suppression
behaviour introduced in rynfar#489.
Fixes: non-coding API clients (Open WebUI, curl, etc.) receiving the
Claude Code persona despite codeSystemPrompt=false in sdk-features.json.
All 55 query.test.ts assertions pass.
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.
Problem
When
codeSystemPromptis explicitly set tofalseviaPATCH /settings/api/features/:adapter, the functionresolveSystemPrompt()returns
{ systemPrompt: "" }unconditionally at line 208, discarding theclient's own system prompt before it is used.
Any non-coding API client (Open WebUI, curl, any OpenAI-compatible tool) that
disables the Claude Code preset via the settings API gets an empty system prompt —
the model ignores their instructions and falls back to the Claude Code persona
from Anthropic's prompt cache.
Root Cause
The defensive empty-string return added in #489 fires before
clientContextis evaluated:
Fix
The
?? ""preserves the original defensive behaviour: when no system promptis provided, an explicit empty string prevents the SDK from reintroducing the
claude_codepreset downstream.Test Results
All 55 existing assertions in
query.test.tspass with no modifications:The existing test
forces systemPrompt='' when codeSystemPrompt false and no systemContextcontinues to pass becauseclientContext ?? ""evaluates to""whenclientContextisundefined.Reproduction
PATCH /settings/api/features/opencodewith{"codeSystemPrompt": false}/v1/chat/completionsrequest with asystemmessageprompt_tokens: 3(system prompt not counted), response reflectsClaude Code persona instead of your system prompt