From 269a1c5452a88a1f9d4117a48f7e7240ac845ced Mon Sep 17 00:00:00 2001 From: sowar1987 <178468696@qq.com> Date: Wed, 21 Jan 2026 14:59:30 +0800 Subject: [PATCH] refactor: reuse placeholder reason description Co-Authored-By: Warp --- internal/util/gemini_schema.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/util/gemini_schema.go b/internal/util/gemini_schema.go index c22e98c9..ddcee040 100644 --- a/internal/util/gemini_schema.go +++ b/internal/util/gemini_schema.go @@ -12,6 +12,8 @@ import ( var gjsonPathKeyReplacer = strings.NewReplacer(".", "\\.", "*", "\\*", "?", "\\?") +const placeholderReasonDescription = "Brief explanation of why you are calling this tool" + // CleanJSONSchemaForAntigravity transforms a JSON schema to be compatible with Antigravity API. // It handles unsupported keywords, type flattening, and schema simplification while preserving // semantic information as description hints. @@ -72,7 +74,7 @@ func removePlaceholderFields(jsonStr string) string { continue } desc := gjson.Get(jsonStr, p+".description").String() - if desc != "Brief explanation of why you are calling this tool" { + if desc != placeholderReasonDescription { continue } jsonStr, _ = sjson.Delete(jsonStr, p) @@ -502,7 +504,7 @@ func addEmptySchemaPlaceholder(jsonStr string) string { // Add placeholder "reason" property reasonPath := joinPath(propsPath, "reason") jsonStr, _ = sjson.Set(jsonStr, reasonPath+".type", "string") - jsonStr, _ = sjson.Set(jsonStr, reasonPath+".description", "Brief explanation of why you are calling this tool") + jsonStr, _ = sjson.Set(jsonStr, reasonPath+".description", placeholderReasonDescription) // Add to required array jsonStr, _ = sjson.Set(jsonStr, reqPath, []string{"reason"})