fix: buildTextBlock cache_control sjson path issue

sjson treats 'cache_control.type' as nested path, creating
{ephemeral: {scope: org}} instead of {type: ephemeral, scope: org}.
Pass the whole map to sjson.SetBytes as a single value.
This commit is contained in:
wykk-12138
2026-04-09 13:58:04 +08:00
parent f6f4640c5e
commit 8783caf313

View File

@@ -1346,10 +1346,8 @@ func checkSystemInstructionsWithSigningMode(payload []byte, strictMode bool, exp
func buildTextBlock(text string, cacheControl map[string]string) string {
block := []byte(`{"type":"text"}`)
block, _ = sjson.SetBytes(block, "text", text)
if cacheControl != nil {
for k, v := range cacheControl {
block, _ = sjson.SetBytes(block, "cache_control."+k, v)
}
if cacheControl != nil && len(cacheControl) > 0 {
block, _ = sjson.SetBytes(block, "cache_control", cacheControl)
}
return string(block)
}