2323import java .util .HashMap ;
2424import java .util .List ;
2525import java .util .Map ;
26+ import org .slf4j .Logger ;
27+ import org .slf4j .LoggerFactory ;
2628import org .springframework .ai .tool .ToolCallback ;
2729import org .springframework .ai .tool .function .FunctionToolCallback ;
2830
3537 */
3638public class ToolConverter {
3739
40+ private static final Logger logger = LoggerFactory .getLogger (ToolConverter .class );
41+
3842 /**
3943 * Creates a tool registry from ADK tools for internal tracking.
4044 *
@@ -120,24 +124,21 @@ public List<ToolCallback> convertToSpringAiTools(Map<String, BaseTool> tools) {
120124 java .util .function .Function <Map <String , Object >, String > toolFunction =
121125 args -> {
122126 try {
123- System . out . println ( "=== DEBUG: Spring AI calling tool '" + tool .name () + "' ===" );
124- System . out . println ("Raw args from Spring AI: " + args );
125- System . out . println ("Args type: " + args .getClass ().getName ());
126- System . out . println ("Args keys: " + args .keySet ());
127+ logger . debug ( " Spring AI calling tool '{}'" , tool .name ());
128+ logger . debug ("Raw args from Spring AI: {}" , args );
129+ logger . debug ("Args type: {}" , args .getClass ().getName ());
130+ logger . debug ("Args keys: {}" , args .keySet ());
127131 for (Map .Entry <String , Object > entry : args .entrySet ()) {
128- System .out .println (
129- " "
130- + entry .getKey ()
131- + " -> "
132- + entry .getValue ()
133- + " ("
134- + entry .getValue ().getClass ().getName ()
135- + ")" );
132+ logger .debug (
133+ " {} -> {} ({})" ,
134+ entry .getKey (),
135+ entry .getValue (),
136+ entry .getValue ().getClass ().getName ());
136137 }
137138
138139 // Handle different argument formats that Spring AI might pass
139140 Map <String , Object > processedArgs = processArguments (args , declaration );
140- System . out . println ("Processed args for ADK: " + processedArgs );
141+ logger . debug ("Processed args for ADK: {}" , processedArgs );
141142
142143 // Call the ADK tool and wait for the result
143144 Map <String , Object > result = tool .runAsync (processedArgs , null ).blockingGet ();
@@ -159,18 +160,17 @@ public List<ToolCallback> convertToSpringAiTools(Map<String, BaseTool> tools) {
159160 // Convert ADK schema to Spring AI JSON schema format
160161 Map <String , Object > springAiSchema =
161162 convertSchemaToSpringAi (declaration .parameters ().get ());
162- System .out .println ("=== DEBUG: Generated Spring AI schema for " + tool .name () + " ===" );
163- System .out .println ("Schema: " + springAiSchema );
163+ logger .debug ("Generated Spring AI schema for {}: {}" , tool .name (), springAiSchema );
164164
165165 // Provide the schema as JSON string using inputSchema method
166166 try {
167167 String schemaJson =
168168 new com .fasterxml .jackson .databind .ObjectMapper ()
169169 .writeValueAsString (springAiSchema );
170170 callbackBuilder .inputSchema (schemaJson );
171- System . out . println ( "=== DEBUG: Set input schema JSON: " + schemaJson + " ===" );
171+ logger . debug ( " Set input schema JSON: {}" , schemaJson );
172172 } catch (Exception e ) {
173- System . err . println ("Error serializing schema to JSON: " + e .getMessage ());
173+ logger . error ("Error serializing schema to JSON: {}" , e .getMessage (), e );
174174 }
175175 }
176176
0 commit comments