From 9e0ab4d11610214e9950ab53d774d9106a4018d7 Mon Sep 17 00:00:00 2001 From: wykk-12138 Date: Thu, 9 Apr 2026 14:03:23 +0800 Subject: [PATCH] fix: build cache_control JSON manually to avoid sjson map marshaling --- internal/runtime/executor/claude_executor.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/runtime/executor/claude_executor.go b/internal/runtime/executor/claude_executor.go index 292335cc..12107a8f 100644 --- a/internal/runtime/executor/claude_executor.go +++ b/internal/runtime/executor/claude_executor.go @@ -1347,7 +1347,17 @@ func buildTextBlock(text string, cacheControl map[string]string) string { block := []byte(`{"type":"text"}`) block, _ = sjson.SetBytes(block, "text", text) if cacheControl != nil && len(cacheControl) > 0 { - block, _ = sjson.SetBytes(block, "cache_control", cacheControl) + // Build cache_control JSON manually to avoid sjson map marshaling issues. + // sjson.SetBytes with map[string]string may not produce expected structure. + cc := `{"type":"ephemeral"` + if s, ok := cacheControl["scope"]; ok { + cc += fmt.Sprintf(`,"scope":"%s"`, s) + } + if t, ok := cacheControl["ttl"]; ok { + cc += fmt.Sprintf(`,"ttl":"%s"`, t) + } + cc += "}" + block, _ = sjson.SetRawBytes(block, "cache_control", []byte(cc)) } return string(block) }