Skip to content

Fix: wrap string system prompts as text block objects#12

Open
Juxsta wants to merge 1 commit intohorselock:mainfrom
Juxsta:fix/string-system-prompt
Open

Fix: wrap string system prompts as text block objects#12
Juxsta wants to merge 1 commit intohorselock:mainfrom
Juxsta:fix/string-system-prompt

Conversation

@Juxsta
Copy link
Copy Markdown

@Juxsta Juxsta commented Feb 8, 2026

The Anthropic API expects system array items to be objects with type and text fields, 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:

[systemPrompt, "user string here"]

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:

[systemPrompt, { type: "text", text: "user string here" }]

Testing

Tested with Graphiti (knowledge graph library) which sends string system prompts.

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