Federico Mariani created CAMEL-23382:
----------------------------------------

             Summary:  Unified Camel AI tool abstraction for route-based tools 
across AI components
                 Key: CAMEL-23382
                 URL: https://issues.apache.org/jira/browse/CAMEL-23382
             Project: Camel
          Issue Type: New Feature
            Reporter: Federico Mariani


tldr; as an user of camel-langchain4j, or camel-spring-ai or camel-openai, I'd 
expect the same behaviour and workflow when implementing tools.

 Currently, _camel-langchain4j-tools_ and _camel-spring-ai-tools_ independently 
implement the same pattern: Camel routes register as LLM-invokable tools via a 
consumer endpoint, a singleton registry (_CamelToolExecutorCache_) maps tags to 
tool specs, and a producer dispatches tool calls to the matching route. Each 
module has its own duplicated copy of this registry and specification classes. 
*camel-openai* only supports external MCP server tools and has no way to use 
Camel routes as tools.                                                          
                                                                                
                                                                           
                  
This issue proposes extracting a shared, framework-agnostic tool abstraction 
(*camel-ai-tools*) that all AI components can use:                              
                                                                                
  
- *ai-tools:toolName* consumer endpoint — defines a Camel route as an 
LLM-invokable tool with metadata (description, parameter schema). No AI 
framework dependency.                                                           
               
- *AiToolRegistry* — shared singleton registry mapping tags to tool specs. 
Replaces the duplicated _CamelToolExecutorCache_ in langchain4j-tools and 
spring-ai-tools.
- *AiToolSpec* — framework-agnostic tool definition holding name, description, 
JSON Schema parameters, and a reference to the Camel processor that implements 
the tool.                                                                      
                                                                                
                                                                                
                                                                             
Each AI component discovers tools from the shared registry via a _tags_ 
parameter and converts them to its native format (_ChatCompletionFunctionTool_ 
for openai, _ToolSpecification_ for langchain4j, _ToolCallback_ for spring-ai). 
            
                                                                                
                                                                                
                                                                             
Example YAML DSL:                                                               
                                                                                
                                                                           

{code:java}
# Define a tool once (framework-agnostic)
- route:                                                                        
                                                                                
                                                                           
    from:
      uri: ai-tools:getFacts                                                    
                                                                                
                                                                           
      parameters:                                                               
                                                                                
                                                                           
        tags: research                                                          
                                                                                
                                                                           
        description: "Get facts about a given topic"                            
                                                                                
                                                                           
        parameter.topic: string                                                 
                                                                                
                                                                           
      steps:                                                                    
                                                                                
                                                                           
        - to: 
"openai:chat-completion?model=qwen3-8b&baseUrl=http://localhost:8001/v1";        
                                                                                
                                                             
                                                                                
                                                                                
                                                                             
# Any AI component can use it                                                   
                                                                                
                                                                           
- route:                                                                        
                                                                                
                                                                           
    from:       
      uri: direct:researcher                                                    
                                                                                
                                                                           
      steps:
        - to: "openai:chat-completion?autoToolExecution=true&tags=research"
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to