[
https://issues.apache.org/jira/browse/CAMEL-23950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18100695#comment-18100695
]
Guillaume Nodet commented on CAMEL-23950:
-----------------------------------------
This issue is being investigated by a coding agent (Claude Code on behalf of
gnodet).
Analysis: Four confirmed gaps between AgentConfiguration and the LangChain4j
AiServices builder API: (1) guardrail instances (not just classes), (2)
beforeToolExecution/afterToolExecution hooks, (3)
maxSequentialToolsInvocations, (4) immediateReturnToolNames. All are mechanical
additions following the CAMEL-23928 pattern.
_Note: This comment was generated by a coding agent and requires manual
verification._
> camel-langchain4j-agent: complete AgentConfiguration coverage of the
> AiServices builder
> ---------------------------------------------------------------------------------------
>
> Key: CAMEL-23950
> URL: https://issues.apache.org/jira/browse/CAMEL-23950
> Project: Camel
> Issue Type: Improvement
> Components: camel-langchain4j-agent
> Reporter: Federico Mariani
> Assignee: Guillaume Nodet
> Priority: Major
>
> Follow-up to CAMEL-23928, which added {{maxToolCallingRoundTrips}},
> {{hallucinatedToolNameStrategy}}, tool error handlers,
> {{compensateOnToolErrors}} and the {{aiServicesCustomizer}} escape hatch.
> Comparing {{AgentConfiguration}} against the full {{AiServices}} builder
> surface at LangChain4j 1.17.2, the following knobs are missing *and matter in
> a Camel context*:
> * *Guardrail instances*: {{inputGuardrails(List<InputGuardrail>)}} /
> {{outputGuardrails(...)}} plus {{inputGuardrailsConfig}} /
> {{outputGuardrailsConfig}}. Today only guardrail *classes* are supported,
> which LangChain4j instantiates via no-arg constructor — in a bean-centric
> Camel application (Spring/Quarkus DI) this blocks any guardrail that needs
> configuration (thresholds, wordlists, vault-sourced patterns) or injected
> collaborators, and it is a prerequisite for CAMEL-23344 (route-based
> guardrails need a {{CamelContext}}-aware instance).
> * {{beforeToolExecution}} / {{afterToolExecution}} consumers — the natural
> hook for per-tool-call logging, Camel events, Micrometer metrics and OTel
> spans; foundation for CAMEL-23861.
> * {{maxSequentialToolsInvocations}} — companion cost-control cap to the
> already-exposed {{maxToolCallingRoundTrips}}; trivial to add.
> * {{immediateReturnToolNames}} — lets a Camel route tool produce the *final*
> answer without a closing LLM round trip (saves one model call per invocation
> for deterministic tools).
> Deliberately *not* exposed (reachable via the existing
> {{aiServicesCustomizer}} escape hatch; document this in the component docs):
> * {{toolSearchStrategy}} — overlaps with the component's own tool-search
> mechanism ({{exposed=false}} + toolSearchTool);
> * {{storeRetrievedContentInChatMemory}} — niche RAG-memory flag;
> * {{AiServiceListener}} registration — users can already attach
> {{ChatModelListener}}s to the {{ChatModel}} bean they inject.
> Out of scope here: {{executeToolsConcurrently(Executor)}} — tracked in
> CAMEL-23952 together with the tool-executor exchange-safety work that permits
> it.
> Also: document (Javadoc) that an {{aiServicesCustomizer}} setting
> {{chatRequestTransformer}} silently replaces the transformer installed by
> {{configureBuilder}} for {{responseFormat}}, breaking
> {{jsonSchema}}/{{outputClass}} structured output.
> Wiring pattern: same as CAMEL-23928 — null-guarded application in
> {{AbstractAgent.configureBuilder()}} plus unit tests in the style of
> {{AgentConfigurationTest}}.
> Related: CAMEL-23928, CAMEL-23929, CAMEL-23344, CAMEL-23861.
> _This issue was drafted by Claude Code on behalf of Federico Mariani._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)