@@ -153,6 +153,8 @@ public class AgentUtils {
153153 public static final String TOKEN_USAGE_PATH = "token_usage_path" ;
154154 private static final String NAME = "name" ;
155155 private static final String DESCRIPTION = "description" ;
156+ private static final String INPUT_SCHEMA = "input_schema" ;
157+ private static final String DEFAULT_INPUT_SCHEMA = "{\" type\" :\" object\" ,\" properties\" :{}}" ;
156158 private static final Pattern ADDITIONAL_PROPERTIES_PATTERN = Pattern
157159 .compile (",\\ s*\" additionalProperties\" \\ s*:\\ s*(?:false|true)" , Pattern .CASE_INSENSITIVE );
158160 public static final String AGENT_LLM_MODEL_ID = "agent_llm_model_id" ;
@@ -240,16 +242,16 @@ public static String addToolsToFunctionCalling(
240242 toolParams .put (NAME , StringEscapeUtils .escapeJson (tool .getName ()));
241243 toolParams .put (DESCRIPTION , StringEscapeUtils .escapeJson (tool .getDescription ()));
242244 Map <String , ?> attributes = tool .getAttributes ();
243- if (attributes == null || !attributes .containsKey ("input_schema" )) {
244- toolParams .put ("attributes.input_schema" , "{ \" type \" : \" object \" , \" properties \" :{}}" );
245+ if (attributes == null || !attributes .containsKey (INPUT_SCHEMA )) {
246+ toolParams .put ("attributes." + INPUT_SCHEMA , DEFAULT_INPUT_SCHEMA );
245247 }
246248 if (attributes != null ) {
247249 for (String key : attributes .keySet ()) {
248250 toolParams .put ("attributes." + key , attributes .get (key ));
249251 }
250252 // For Gemini, clean input_schema to remove additionalProperties
251- if (parameters .containsKey ("gemini.schema.cleaner" ) && attributes .containsKey ("input_schema" )) {
252- String schema = String .valueOf (attributes .get ("input_schema" ));
253+ if (parameters .containsKey ("gemini.schema.cleaner" ) && attributes .containsKey (INPUT_SCHEMA )) {
254+ String schema = String .valueOf (attributes .get (INPUT_SCHEMA ));
253255 String cleanedSchema = removeAdditionalPropertiesFromSchema (schema );
254256 toolParams .put ("attributes.input_schema_cleaned" , cleanedSchema );
255257 }
@@ -1265,10 +1267,10 @@ public static Map<String, Tool> wrapFrontendToolsAsToolObjects(List<Map<String,
12651267
12661268 Object parameters = frontendTool .get ("parameters" );
12671269 if (parameters != null ) {
1268- toolAttributes .put ("input_schema" , gson .toJson (parameters ));
1270+ toolAttributes .put (INPUT_SCHEMA , gson .toJson (parameters ));
12691271 } else {
12701272 Map <String , Object > emptySchema = Map .of ("type" , "object" , "properties" , Map .of ());
1271- toolAttributes .put ("input_schema" , gson .toJson (emptySchema ));
1273+ toolAttributes .put (INPUT_SCHEMA , gson .toJson (emptySchema ));
12721274 }
12731275
12741276 Tool frontendToolObj = new AGUIFrontendTool (toolName , toolDescription , toolAttributes );
0 commit comments