CAMEL-23928: Add tool-calling behavior tests and documentation for AgentConfiguration - #26027
Conversation
Add behavioral unit and integration tests covering hallucinated tool name recovery, max tool round trips, tool execution error handling, and the AiServices customizer hook. Document AgentConfiguration tool-calling options and the customizer escape hatch in the component guide. Co-authored-by: Cursor <cursoragent@cursor.com>
Sync langchain4j-agent component documentation into the catalog mirror and use a less brittle assertion for max tool round-trip enforcement. Co-authored-by: Cursor <cursoragent@cursor.com>
Review follow-up (Bugbot + security review)AI-generated comment on behalf of atiaomar1978-hub Findings addressed in latest commits
Review notes (no code change required)
Tests run locallymvn test -pl components/camel-ai/camel-langchain4j-agent-api,components/camel-ai/camel-langchain4j-agent -am \
-Dtest=AgentConfigurationToolCallingBehaviorTest,LangChain4jAgentAiServicesCustomizerTest \
-DfailIfNoTests=false -Ddevelocity.buildCache.local.enabled=falseAll 6 new tests pass. |
davsclaus
left a comment
There was a problem hiding this comment.
Reviewed against the project's rules and standards (test conventions, doc/catalog sync, commit format, JIRA ownership).
Verification performed:
- Checked out the branch and ran the two new test classes locally (CI has not triggered any runs on this branch yet): all 6 new tests pass.
- Confirmed
formatter:validate/impsort:checkpass on both touched modules. - Confirmed every
AgentConfigurationmethod referenced (withMaxToolCallingRoundTrips,withHallucinatedToolNameStrategy,withToolExecutionErrorHandler,withToolArgumentsErrorHandler,withCompensateOnToolErrors,withExecuteToolsConcurrently,withAiServicesCustomizer) already exists onmain(landed via #24492), so this PR is purely additive coverage + docs as described. - Confirmed the catalog mirror (
catalog/camel-catalog/.../langchain4j-agent-component.adoc) is byte-identical to the source doc change. - Tests use AssertJ assertions and no
Thread.sleep(), consistent with this project's test conventions. - No scope drift: only tests + docs are touched, matching the PR description.
One small documentation suggestion left as an inline comment — not blocking.
This review does not replace specialized review tools (CodeRabbit/Sourcery) or static analysis (SonarCloud).
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 11 tested, 26 compile-only — current: 10 all testedMaveniverse Scalpel detected 37 affected modules (current approach: 10).
|
gnodet
left a comment
There was a problem hiding this comment.
Clean, well-structured PR that adds meaningful behavioral test coverage and clear documentation for the CAMEL-23928 tool-calling options and AiServices customizer. Tests fill a real gap between existing getter/setter unit tests and URI parameter tests.
Highlights:
- Tests verify meaningful end-to-end behavior: hallucinated tool name recovery, max round-trip enforcement, error handler with compensation, and customizer-driven
beforeToolExecutionwiring. - Documentation is well-organized with a quick-reference AsciiDoc table, realistic code examples, and accurate explanation of customizer ordering.
- Catalog mirror properly synchronized, no convention violations.
📋 PR Metadata
| Aspect | Current | Suggested |
|---|---|---|
| Category | (unlabeled) | test |
| Milestone | (none) | 4.23.0 |
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Summary
The core CAMEL-23928 API (first-class tool-calling options on
AgentConfigurationand thewithAiServicesCustomizer()escape hatch wired throughAbstractAgent.configureBuilder()) is already onmainsince #24492. This PR completes the ticket by adding behavioral test coverage and component documentation so the feature is discoverable and verified end-to-end.Changes
AgentConfigurationToolCallingBehaviorTest): verify hallucinated tool name recovery, max tool round-trip enforcement, tool execution error handler + compensation, and customizer-drivenbeforeToolExecutionwiring viaAgentWithoutMemory.LangChain4jAgentAiServicesCustomizerTest): verify the same options through thelangchain4j-agentcomponent withagentConfigurationbeans and Camel route tools.langchain4j-agent-component.adoc): document first-class tool-calling methods and the AiServices customizer escape hatch for options likebeforeToolExecution,afterToolExecution, andtoolSearchStrategy.Testing
mvn test -pl components/camel-ai/camel-langchain4j-agent-api,components/camel-ai/camel-langchain4j-agent -am \ -Dtest=AgentConfigurationToolCallingBehaviorTest,LangChain4jAgentAiServicesCustomizerTest \ -DfailIfNoTests=false -Ddevelocity.buildCache.local.enabled=falseAll 6 new tests pass locally.
JIRA
https://issues.apache.org/jira/browse/CAMEL-23928
AI-generated PR description on behalf of atiaomar1978-hub