Claus Ibsen created CAMEL-23928:
-----------------------------------

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


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