fix: remove invalid org scope and match Claude Code block layout
This commit is contained in:
@@ -1302,16 +1302,20 @@ func checkSystemInstructionsWithSigningMode(payload []byte, strictMode bool, exp
|
|||||||
billingBlock := fmt.Sprintf(`{"type":"text","text":"%s"}`, billingText)
|
billingBlock := fmt.Sprintf(`{"type":"text","text":"%s"}`, billingText)
|
||||||
|
|
||||||
// Build system blocks matching real Claude Code structure.
|
// Build system blocks matching real Claude Code structure.
|
||||||
// Use buildTextBlock instead of fmt.Sprintf to properly escape multi-line text.
|
// Important: Claude Code's internal cacheScope='org' does NOT serialize to
|
||||||
// Cache control scopes: 'org' for agent block, 'global' for core prompt.
|
// scope='org' in the API request. Only scope='global' is sent explicitly.
|
||||||
agentBlock := buildTextBlock("You are Claude Code, Anthropic's official CLI for Claude.",
|
// The system prompt prefix block is sent without cache_control.
|
||||||
map[string]string{"type": "ephemeral", "scope": "org"})
|
agentBlock := buildTextBlock("You are Claude Code, Anthropic's official CLI for Claude.", nil)
|
||||||
introBlock := buildTextBlock(claudeCodeIntro,
|
staticPrompt := strings.Join([]string{
|
||||||
map[string]string{"type": "ephemeral", "scope": "global"})
|
claudeCodeIntro,
|
||||||
systemBlock := buildTextBlock(claudeCodeSystem, nil)
|
claudeCodeSystem,
|
||||||
doingTasksBlock := buildTextBlock(claudeCodeDoingTasks, nil)
|
claudeCodeDoingTasks,
|
||||||
|
claudeCodeToneAndStyle,
|
||||||
|
claudeCodeOutputEfficiency,
|
||||||
|
}, "\n\n")
|
||||||
|
staticBlock := buildTextBlock(staticPrompt, map[string]string{"scope": "global"})
|
||||||
|
|
||||||
systemResult := "[" + billingBlock + "," + agentBlock + "," + introBlock + "," + systemBlock + "," + doingTasksBlock + "]"
|
systemResult := "[" + billingBlock + "," + agentBlock + "," + staticBlock + "]"
|
||||||
payload, _ = sjson.SetRawBytes(payload, "system", []byte(systemResult))
|
payload, _ = sjson.SetRawBytes(payload, "system", []byte(systemResult))
|
||||||
|
|
||||||
// Collect user system instructions and prepend to first user message
|
// Collect user system instructions and prepend to first user message
|
||||||
|
|||||||
Reference in New Issue
Block a user