CAMEL-23382: camel-ai-tool - align spring-ai-chat with camel-ai-tool …#24862
Conversation
…component Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
left a comment
There was a problem hiding this comment.
Claude Code on behalf of gnodet
Clean migration — well-structured step in the `camel-spring-ai-tools` → `camel-ai-tool` unification roadmap.
Changes reviewed:
Bridge adapter (`AiToolSpecToSpringAi`) ✅
- Converts framework-agnostic `AiToolSpec` → Spring AI `ToolCallback` via `FunctionToolCallback.builder()`
- Exhaustive `AiToolResult` subtype handling: `Success` returns value, `ArgumentError` returns message, `ExecutionError` logs WARN and returns generic error
- Exchange lifecycle is clean: `createExchange()` in try, `releaseExchange()` in finally
- Properly passes `inputSchema` when the spec has a JSON schema
Producer wiring (`SpringAiChatProducer`) ✅
- `CamelToolExecutorCache.getInstance()` → `AiToolRegistry.getOrCreate(getCamelContext())` — context-scoped instead of singleton
- Tool dedup via `LinkedHashSet` prevents duplicates when tags overlap (e.g., a tool tagged `weather,info` appearing in both tag queries)
- Clean stream pipeline: collect unique specs → map to ToolCallback
Tests ✅
- `Thread.sleep(500/1000)` → `Awaitility.await().atMost(5/10, SECONDS).untilAsserted(...)` — proper async assertion
- Removed manual `@AfterEach` cache cleanup — registry lifecycle tied to CamelContext
- `testMultipleToolsWithSameTag` → `testToolExecutionWithDifferentInput` — better name for what it actually tests
Documentation ✅
- Component docs: all `spring-ai-tools` references → `ai-tool`, xref links updated
- Upgrade guide: clear before/after migration example, notes that chat producer URI is unchanged, lists the dependency swap
No issues found.
|
🌟 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: 10 tested, 28 compile-only — current: 9 all testedMaveniverse Scalpel detected 38 affected modules (current approach: 9).
|
oscerd
left a comment
There was a problem hiding this comment.
LGTM. Nice migration — routing spring-ai-chat through the unified AiToolRegistry/AiToolExecutor rather than its own tool-call handling, and importantly it preserves the security hardening: the bridge passes the raw untrusted LLM args map straight to AiToolExecutor.execute(...) (AiToolSpecToSpringAi.java:46), which drops undeclared args, validates required ones, and rejects camel*/org.apache.camel.* names case-insensitively before setHeader — the CVE-2025-27636 guard — so there's no raw unfiltered header map in the production path. It also follows AiToolResult's note by returning a generic "Tool execution failed" to the LLM for ExecutionError (logging the detail at WARN) while surfacing only framework-generated ArgumentError messages. Tests present, Thread.sleep→Awaitility, upgrade-guide entry added, CI green.
Reviewed with Claude Code on behalf of Andrea Cosentino. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.
…component
Description
Step 3: Wire camel-spring-ai-chat producer to discover tools from AiToolRegistry
Summary
Migrate the
camel-spring-ai-chatproducer fromcamel-spring-ai-tools(CamelToolExecutorCache) to the unifiedcamel-ai-toolmodule (AiToolRegistry).AiToolSpecToSpringAiconvertsAiToolSpec→ Spring AIToolCallback, with explicit handling of allAiToolResultsubtypes and WARN logging on execution errorsLinkedHashSetto prevent duplicate tools when tags overlapcamel-spring-ai-tools→camel-ai-toolin pom.xmlAiToolRegistry, replacedThread.sleep()with AwaitilityNo changes to other modules.
Roadmap
camel-ai-toolmodule - CAMEL-23382: camel-ai-tool - create unified AI tool component #24473camel-langchain4j-agentproducer toAiToolRegistrycamel-spring-ai-chatproducer toAiToolRegistrycamel-langchain4j-toolsproducer toAiToolRegistrycamel-langchain4j-toolsconsumer, removecamel-spring-ai-toolscamel-openai