[ 
https://issues.apache.org/jira/browse/CAMEL-23928?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-23928:
--------------------------------
    Fix Version/s: 4.22.0

> camel-langchain4j-agent - Add AiServices builder customizer hook to 
> AgentConfiguration
> --------------------------------------------------------------------------------------
>
>                 Key: CAMEL-23928
>                 URL: https://issues.apache.org/jira/browse/CAMEL-23928
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-langchain4j-agent
>            Reporter: Claus Ibsen
>            Priority: Major
>             Fix For: 4.22.0
>
>
> AgentConfiguration does not expose several important LangChain4j AiServices 
> builder options that are needed for agent runtimes, specifically around 
> tool-calling error handling and control:
> - hallucinatedToolNameStrategy
> - toolArgumentsErrorHandler
> - toolExecutionErrorHandler
> - maxToolCallingRoundTrips
> - beforeToolExecution / afterToolExecution
> - executeToolsConcurrently
> - toolSearchStrategy
> - compensateOnToolErrors
> *Concrete use case:* an LLM hallucinated a task_complete tool name, and 
> LangChain4j's hallucinatedToolNameStrategy would handle this gracefully, but 
> it is not reachable through Camel's agent abstraction.
> The createAiAgentService() methods in AgentWithMemory / AgentWithoutMemory 
> are private, so subclassing cannot intercept the builder. The only current 
> workaround is implementing AgentFactory to return a fully custom Agent, but 
> that requires reimplementing all the common setup logic from 
> AbstractAgent.configureBuilder() (tool providers, MCP, guardrails, RAG, 
> response format).
> *Proposed solution (two parts):*
> 1. *First-class options:* Expose the most important tool-calling options 
> directly on AgentConfiguration as dedicated fields with fluent setters, so 
> they are easy to discover and configure in Camel (e.g. 
> withMaxToolCallingRoundTrips(), withHallucinatedToolNameStrategy(), 
> withToolExecutionErrorHandler(), etc.).
> 2. *Customizer escape hatch:* Add a Consumer<AiServices<?>> customizer 
> callback to AgentConfiguration that is invoked in 
> AbstractAgent.configureBuilder() just before the method returns. This lets 
> users configure any AiServices builder option (including future ones) without 
> Camel needing to individually wrap each one, and avoids having to reimplement 
> configureBuilder() via AgentFactory.



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

Reply via email to