[camel-main] Fixes #8768. Add CamelAiToolProvider bridge and @CamelAiTools tag filtering for langchain4j - #8926
Conversation
|
@zbendhiba , @jamesnetherton FYI. |
|
Looks good to me mostly. Some feedback: 1.
|
ae5f68f to
4716c42
Compare
|
I addressed the feedback in the new commit (which can be squashed with the original one). |
|
Feel free to merge apache/camel#25154 so we can move this forwards. |
4716c42 to
6aae5ec
Compare
ffaff10 to
fcc0d6b
Compare
|
PR is rebased and squashed into 1 commit. |
f571c63 to
e62bdb8
Compare
…ag filtering for langchain4j
Bridges Camel's AiToolRegistry to langchain4j's ToolProvider SPI in
extensions-support/langchain4j. When both camel-ai-tool and
quarkus-langchain4j are on the classpath, the deployment processor
auto-registers CamelAiToolProvider as a CDI bean, making Camel AI tools
available to @RegisterAiService AI services without explicit wiring.
Introduces @CamelAiTools("tag") annotation for per-AI-service tool
filtering via a CDI interceptor + ThreadLocal pattern. Tag resolution:
ThreadLocal present -> getToolsByTag(), absent -> getAllTools(). Services
without @CamelAiTools always see all tools.
Includes integration tests with mock ToolCallingChatModels verifying
end-to-end tool invocation and tag isolation across weather + admin
AI services, plus an Ollama-based test behind -Pollama.
Document LangChain4j integration and @CamelAiTools tag filtering in ai-tool usage.adoc
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e62bdb8 to
59a416a
Compare
Summary
Fixes #8768
AiToolRegistryto langchain4j'sToolProviderSPI viaCamelAiToolProviderinextensions-support/langchain4j. When bothcamel-ai-toolandquarkus-langchain4jare on the classpath, the deployment processor auto-registersCamelAiToolProvideras a CDI bean — all Camelai-tool:routes become available to@RegisterAiServiceAI services without explicit wiring.@CamelAiTools("tag")annotation for per-AI-service tool filtering via a CDI interceptor + ThreadLocal pattern. Services annotated with a tag only see tools matching that tag; services without the annotation see all tools.camel-langchain4j-agentas an explicit dependency (it is optional in the support module and not brought in transitively). This is documented inusage.adoc.Key files
CamelAiToolProvider.javaToolProviderimplementation bridgingAiToolRegistry→ langchain4jCamelAiTools.java@InterceptorBindingannotation carrying the tag valueCamelAiToolsInterceptor.javaSupportQuarkusLangchain4jProcessor.java@CamelAiToolsand CDI bean registrationusage.adocTest plan
./mvnw verify -f integration-tests/ai-tool-langchain4j— 6 mock tests pass (weather/admin chat, tag registry filtering, wrong-tag isolation)./mvnw verify -f integration-tests/ai-tool-langchain4j -Dollama.test=true -Pollama— real LLM tests with OllamawrongTagShouldNotExposeWeatherTool— mock model conditionally callsgetWeatheronly if visible; confirms test fails when interceptor is broken🤖 Generated with Claude Code