Fix: wrap string system prompts as text block objects#12
Open
Juxsta wants to merge 1 commit intohorselock:mainfrom
Open
Fix: wrap string system prompts as text block objects#12Juxsta wants to merge 1 commit intohorselock:mainfrom
Juxsta wants to merge 1 commit intohorselock:mainfrom
Conversation
The Anthropic API expects system array items to be objects with type and text fields, not raw strings. When receiving a string system prompt, now properly wraps it as {type:"text", text:...}
This fixes errors when clients send the system prompt as a plain string rather than an array of content blocks.
pixelnull
added a commit
to pixelnull/claude-code-proxy
that referenced
this pull request
Apr 7, 2026
Anthropic requires system array items to be typed text blocks. When a client sends system as a plain string (SillyTavern's Claude transformer, Graphiti, etc.), the previous code built a mixed array [obj, string] which Anthropic rejects with invalid_request_error. Wrap the string in a {type:'text', text} block.
Same fix as upstream PR horselock#12 by Juxsta.
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.
The Anthropic API expects system array items to be objects with
typeandtextfields, not raw strings.Problem
When a client sends the system prompt as a plain string rather than an array of content blocks, the proxy previously created an invalid array like:
This causes Anthropic API errors since the second element is a raw string instead of a content block object.
Solution
Now properly wraps string system prompts:
Testing
Tested with Graphiti (knowledge graph library) which sends string system prompts.