Claus Ibsen created CAMEL-27314:
-----------------------------------

             Summary: camel-openai - autoToolExecution and the docs describe 
the tool loop for MCP servers only, but route tools (tags) run in the same loop
                 Key: CAMEL-27314
                 URL: https://issues.apache.org/jira/browse/CAMEL-27314
             Project: Camel
          Issue Type: Improvement
          Components: camel-openai
            Reporter: Claus Ibsen
             Fix For: 4.25.0


The tool loop of camel-openai runs two kinds of tools: MCP server tools 
({{mcpServer.*}}) and route tools ({{tags}}, routes that start with 
{{ai-tool:}}). The option descriptions and the openai docs describe the loop 
for MCP servers only.

*Where it says MCP only*
* {{autoToolExecution}}: "When true and MCP servers are configured, 
automatically execute tool calls and loop back to the model."
* {{maxAgenticTokens}}: "... allowed across the MCP agentic loop."
* The chat-completion body type text: "text when MCP tools run in a loop".
* openai-component.adoc, the streaming note: "When MCP tools with 
autoToolExecution are active, streaming automatically falls back to 
non-streaming". Check whether route tools do the same.
* openai-mcp.adoc explains the loop and {{autoToolExecution=false}} with MCP 
servers only. The openai docs have no example with {{tags}}.

*What the code does*
{{McpToolCallExecutor}} runs route tools as well as MCP tools. 
{{openai:tool-execution}} without tools fails with "Configure mcpServer.* 
parameters and/or the tags option". An endpoint with {{tags: shop}}, two 
{{ai-tool}} routes and no MCP server runs the tool calls of the model and 
returns its final answer. The ai/agent-tools example 
(apache/camel-jbang-examples#140) does this; its Citrus test passes on 
4.24.0-SNAPSHOT.

*Why it matters*
Coding agents read these descriptions through the catalog and the Camel MCP 
server. A model that reads "when MCP servers are configured" may add an MCP 
server that it does not need, or handle the tool calls in the route itself.

*Proposed change*
* {{autoToolExecution}}: "When true, run the tool calls the model asks for, 
both MCP tools (mcpServer.*) and route tools (tags), and send the results back 
to the model until it answers. When false, the tool calls are returned as the 
message body for the route to handle."
* {{maxAgenticTokens}} and the body type text: say "tool loop" instead of "MCP 
agentic loop" and "MCP tools".
* openai docs: a short section on route tools, with {{tags}} on the endpoint 
and one {{ai-tool}} route, in Java, XML and YAML tabs, and a link to the 
ai-tool component docs.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to