Claus Ibsen created CAMEL-26357:
-----------------------------------

             Summary: camel-ai-tool - validate tool arguments against the input 
schema and results against the output schema
                 Key: CAMEL-26357
                 URL: https://issues.apache.org/jira/browse/CAMEL-26357
             Project: Camel
          Issue Type: Improvement
          Components: camel-mcp-server, camel-ai
            Reporter: Claus Ibsen
             Fix For: 4.24.0


{{AiToolExecutor}} checks only that the required argument names are present. 
Types, enums, formats and nested objects in the input schema are not checked, 
so a wrong call reaches the route. With an {{outputSchema}}, the result is 
parsed as JSON but never validated, so a route can return {{structuredContent}} 
that breaks the schema it advertises.

h3. Proposal

* At startup, check the declared input and output schemas against their JSON 
Schema meta-schema (draft 2020-12 unless {{$schema}} says otherwise). A broken 
schema stops the route.
* Validate the arguments before the route runs. A failure is an 
{{ArgumentError}} naming the location of the bad value, for example 
{{$.address.zip: must be a string}}. That message is returned as-is, as 
argument errors are today, so the model can correct the call.
* Validate the result against {{outputSchema}}. A mismatch is a tool error with 
a generic message, and the details go to the log.
* This lives in {{camel-ai-tool}}, so the standalone MCP server and the 
in-process agents (langchain4j-agent, openai, spring-ai-chat) all get it.
* An option to turn validation off, for routes that rely on loose arguments 
today. If the default is on, that's an upgrade-guide entry.

_Filed by Claude Code on behalf of davsclaus_



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

Reply via email to