From 1eeefbf190538a7eca94583dfe6a83eb5dfab65c Mon Sep 17 00:00:00 2001 From: Dominic Robinson Date: Sun, 8 Mar 2026 18:17:41 +0000 Subject: [PATCH 1/2] fix: Preserve system prompt when sent as a string instead of content block array --- internal/runtime/executor/claude_executor.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/runtime/executor/claude_executor.go b/internal/runtime/executor/claude_executor.go index 3dd4ca5e2d..215e2f0abe 100644 --- a/internal/runtime/executor/claude_executor.go +++ b/internal/runtime/executor/claude_executor.go @@ -1266,6 +1266,13 @@ func checkSystemInstructionsWithMode(payload []byte, strictMode bool) []byte { } return true }) + } else if system.Type == gjson.String && system.String() != "" { + // The Anthropic API allows "system" to be a plain string as well as an array + // of content blocks. Convert the string into a content block so it is preserved. + partJSON := `{"type":"text","text":""}` + partJSON, _ = sjson.Set(partJSON, "text", system.String()) + partJSON, _ = sjson.Set(partJSON, "cache_control.type", "ephemeral") + result += "," + partJSON } result += "]" From ad232c37c35e4e05f73f87bc09b4f97e744778b0 Mon Sep 17 00:00:00 2001 From: Dominic Robinson Date: Sun, 8 Mar 2026 18:31:12 +0000 Subject: [PATCH 2/2] refactor: Apply suggestion from @gemini-code-assist[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- internal/runtime/executor/claude_executor.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/runtime/executor/claude_executor.go b/internal/runtime/executor/claude_executor.go index 215e2f0abe..a87e5ce29b 100644 --- a/internal/runtime/executor/claude_executor.go +++ b/internal/runtime/executor/claude_executor.go @@ -1269,9 +1269,8 @@ func checkSystemInstructionsWithMode(payload []byte, strictMode bool) []byte { } else if system.Type == gjson.String && system.String() != "" { // The Anthropic API allows "system" to be a plain string as well as an array // of content blocks. Convert the string into a content block so it is preserved. - partJSON := `{"type":"text","text":""}` - partJSON, _ = sjson.Set(partJSON, "text", system.String()) - partJSON, _ = sjson.Set(partJSON, "cache_control.type", "ephemeral") +partJSON := `{"type":"text","cache_control":{"type":"ephemeral"}}` +partJSON, _ = sjson.Set(partJSON, "text", system.String()) result += "," + partJSON } result += "]"