From fa454b1b99f2c6866f756773c96f91cad8353173 Mon Sep 17 00:00:00 2001 From: cyhhao Date: Thu, 29 Jan 2026 15:37:07 +0800 Subject: [PATCH] fix: align Claude Code system banner with opencode latest --- backend/internal/service/gateway_service.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/internal/service/gateway_service.go b/backend/internal/service/gateway_service.go index 8363ba66..47ea8593 100644 --- a/backend/internal/service/gateway_service.go +++ b/backend/internal/service/gateway_service.go @@ -39,9 +39,10 @@ const ( claudeAPICountTokensURL = "https://api.anthropic.com/v1/messages/count_tokens?beta=true" stickySessionTTL = time.Hour // 粘性会话TTL defaultMaxLineSize = 40 * 1024 * 1024 - // Keep a trailing blank line so that when upstream concatenates system strings, - // the injected Claude Code banner doesn't run into the next system instruction. - claudeCodeSystemPrompt = "You are Claude Code, Anthropic's official CLI for Claude.\n\n" + // Canonical Claude Code banner. Keep it EXACT (no trailing whitespace/newlines) + // to match real Claude CLI traffic as closely as possible. When we need a visual + // separator between system blocks, we add "\n\n" at concatenation time. + claudeCodeSystemPrompt = "You are Claude Code, Anthropic's official CLI for Claude." maxCacheControlBlocks = 4 // Anthropic API 允许的最大 cache_control 块数量 )