diff --git a/src-tauri/src/core/server/proxy.rs b/src-tauri/src/core/server/proxy.rs index 92d99f05d..2195c5048 100644 --- a/src-tauri/src/core/server/proxy.rs +++ b/src-tauri/src/core/server/proxy.rs @@ -176,6 +176,20 @@ fn transform_anthropic_to_openai(body: &serde_json::Value) -> Option serde_json::Value::Array(super::responses_shim::merge_system_messages( + arr.clone(), + )), + None => openai_messages, + }; + let stream = body .get("stream") .and_then(|v| v.as_bool()) diff --git a/src-tauri/src/core/server/responses_shim.rs b/src-tauri/src/core/server/responses_shim.rs index ba9f2dd5b..354c759cb 100644 --- a/src-tauri/src/core/server/responses_shim.rs +++ b/src-tauri/src/core/server/responses_shim.rs @@ -111,7 +111,10 @@ pub fn responses_request_to_chat(body: &Value) -> Value { /// than one system message or places one after the first turn — which Codex /// readily does by combining `instructions` with developer/system input items. /// Order of the remaining (non-system) messages is preserved. -fn merge_system_messages(messages: Vec) -> Vec { +/// +/// Also reused by the Anthropic `/messages` proxy path (Claude Code), which can +/// likewise emit more than one system message after conversion. +pub(crate) fn merge_system_messages(messages: Vec) -> Vec { let mut system_parts: Vec = Vec::new(); let mut rest: Vec = Vec::with_capacity(messages.len());