davsclaus commented on code in PR #25497:
URL: https://github.com/apache/camel/pull/25497#discussion_r3788724843


##########
components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/McpToolState.java:
##########
@@ -22,24 +22,33 @@
 
 import com.openai.models.chat.completions.ChatCompletionFunctionTool;
 import io.modelcontextprotocol.client.McpSyncClient;
+import org.apache.camel.component.ai.tool.AiToolSpec;
 
 /**
- * Immutable snapshot of the MCP tool state shared by all concurrent exchanges.
+ * Immutable snapshot of the MCP and route-based tool state shared by all 
concurrent exchanges.
  */
 record McpToolState(
         List<ChatCompletionFunctionTool> tools,
         Map<String, McpSyncClient> toolClientMap,
         Map<String, String> toolToServerName,
-        Set<String> returnDirectTools) {
+        Set<String> returnDirectTools,
+        Map<String, AiToolSpec> routeTools) {
 
     McpToolState {
         tools = List.copyOf(tools);
         toolClientMap = Map.copyOf(toolClientMap);
         toolToServerName = Map.copyOf(toolToServerName);
         returnDirectTools = Set.copyOf(returnDirectTools);
+        routeTools = Map.copyOf(routeTools);
     }
 
     static McpToolState empty() {
-        return new McpToolState(List.of(), Map.of(), Map.of(), Set.of());
+        return new McpToolState(List.of(), Map.of(), Map.of(), Set.of(), 
Map.of());

Review Comment:
   These use fully-qualified class names (`java.util.Set`, `java.util.HashSet`) 
but both are already imported at the top of this file. Per project conventions, 
use the simple class names:
   ```suggestion
       Set<String> knownToolNames() {
           Set<String> names = new HashSet<>(toolClientMap.keySet());
   ```



##########
components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/McpToolCallExecutor.java:
##########
@@ -254,6 +263,56 @@ private ToolResult 
executeOne(ChatCompletionMessageToolCall toolCall, McpToolSta
         }
     }
 
+    private ToolResult executeRouteTool(
+            ChatCompletionMessageToolCall toolCall,
+            AiToolSpec spec,
+            McpToolState toolState,
+            OpenAIConfiguration config)
+            throws Exception {
+        String toolName = toolCall.asFunction().function().name();
+        String argsJson = toolCall.asFunction().function().arguments();
+
+        LOG.debug("Executing route tool '{}' with args: {}", toolName, 
argsJson);
+
+        try {
+            Map<String, Object> argsMap = OBJECT_MAPPER.readValue(argsJson, 
Map.class);
+            Exchange toolExchange = 
spec.getConsumer().getEndpoint().createExchange();

Review Comment:
   `release` is set to `true` and never changed — the conditional is always 
entered. Remove the variable and call `releaseExchange` unconditionally in the 
finally block.
   ```suggestion
               boolean release = true;
   ```
   
   Should become just removing the variable and changing `if (release) {` to 
unconditional.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to