gnodet opened a new pull request, #25289:
URL: https://github.com/apache/camel/pull/25289

   ## Summary
   
   _Claude Code on behalf of gnodet_
   
   Extends the `camel-openai` component to discover and execute Camel route 
tools registered via the shared `AiToolRegistry`, alongside existing MCP tools. 
This implements **Step 6** of the unified AI tool abstraction design 
([CAMEL-23382](https://issues.apache.org/jira/browse/CAMEL-23382)).
   
   Route authors can now expose Camel routes as AI tools via `ai-tool:` 
consumer endpoints and have them automatically available to OpenAI models 
during function-calling loops — no MCP server required.
   
   ### Changes
   
   - **Dependency**: Add `camel-ai-tool` compile dependency to `camel-openai`
   - **Configuration**: Add `tags` parameter to `OpenAIConfiguration` for 
filtering tools by tag from the shared `AiToolRegistry`
   - **Converter**: Create `AiToolSpecToOpenAI` that transforms `AiToolSpec` 
into OpenAI `ChatCompletionFunctionTool` using `parametersJsonSchema` (follows 
the same pattern as `McpToolConverter`)
   - **OpenAIProducer**: Extend the agentic loop to discover Camel route tools 
via `AiToolRegistry.getOrCreate(context)`, convert them to OpenAI function 
tools, and dispatch via `AiToolExecutor.execute()` with exchange isolation 
(`ExchangeHelper.createCopy`)
   - **OpenAIToolExecutionProducer**: Same extension for manual tool-loop routes
   - **Error handling**: Both producers check Camel route tools first, then 
fall back to MCP; hallucinated tool name and tool execution error strategies 
apply to both sources
   - **Tests**: 8 unit tests in `AiToolSpecToOpenAITest` covering full spec 
conversion, no parameters, no description, default type, required arrays, empty 
schema, invalid schema, and `additionalProperties:false`
   
   ### Usage Example
   
   ```java
   // Register a route as an AI tool
   from("ai-tool:getWeather?description=Get current weather&tags=weather"
       + "&parameters.city=string&parameters.city.description=City 
name&parameters.city.required=true")
       .process(exchange -> {
           String city = exchange.getIn().getHeader("city", String.class);
           exchange.getIn().setBody("Sunny, 22°C in " + city);
       });
   
   // OpenAI will auto-discover and call it
   from("direct:chat")
       
.to("openai:chat-completion?model=gpt-4o&tags=weather&autoToolExecution=true");
   ```
   
   ## Test Plan
   
   - [x] All 163 existing unit tests pass (including updated 
`OpenAIToolErrorStrategyTest`)
   - [x] 8 new `AiToolSpecToOpenAITest` tests pass
   - [x] Code formatted with `mvn formatter:format impsort:sort`
   - [x] Generated files regenerated and committed
   - [ ] CI build passes
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   Co-Authored-By: Claude Opus 4.6 <[email protected]>


-- 
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