You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "Croway (via GitHub)" <gi...@apache.org> on 2026/08/05 09:53:53 UTC

[PR] CAMEL-24212: camel-spring-ai - upgrade to Spring AI 2.0 [camel]

Croway opened a new pull request, #25354:
URL: https://github.com/apache/camel/pull/25354

   Fixes [CAMEL-24212](https://issues.apache.org/jira/browse/CAMEL-24212).
   
   ## Why
   
   Spring AI 1.1 targets Spring Boot 3.5 and Spring Framework 6. Camel is already on Spring Boot 4.1 and Spring Framework 7, which is the baseline Spring AI 2.0 was designed for, so `camel-spring-ai` currently ships an unsupported pairing.
   
   It also fixes a version split that already exists in the build: `parent/pom.xml` manages `mcp-java-sdk-version` 2.0.0 for `camel-mcp-server`, `camel-mcp-server-api` and `camel-openai`, but `camel-spring-ai-chat` drags in MCP SDK **0.18.2** transitively through Spring AI 1.1.7. After this change both are on 2.0.0.
   
   This picks up where dependabot's #24009 stopped — that PR was closed because the artifact rename below needs a manual change, not because the upgrade was rejected.
   
   ## Changes
   
   * `spring-ai-advisors-vector-store` → `spring-ai-vector-store-advisor` (the old artifact was last published at 2.0.0-M8). This is the error that stopped #24009.
   * `SpringAiChatMcpManager` no longer binds to a Jackson generation. The stdio transport takes `McpJsonDefaults.getMapper()` instead of constructing a Jackson 2 `ObjectMapper`, so it works with whichever MCP JSON provider is on the classpath (Spring AI 2.0 moved to Jackson 3).
   * `ChatClient.ChatClientRequestSpec.options()` now takes the options **builder**.
   * `ImageOptionsBuilder.N()` → `n()`.
   
   ### toolNames
   
   Spring AI 2.0 removed `ChatClientRequestSpec.toolNames(String...)` together with `SpringBeanToolCallbackResolver`, so the component resolves the names itself. Each name is looked up, in order, against:
   
   1. a `ToolCallbackResolver` bound in the registry — Spring Boot applications get Spring AI's auto-configured one, which is built from the `ToolCallback` and `ToolCallbackProvider` beans;
   2. the tools discovered via `tags` and configured via `toolCallbacks`, matched on tool definition name;
   3. a `ToolCallback` bound in the registry under that name.
   
   An unresolvable name now fails the exchange with a message listing the available tools, rather than being silently dropped.
   
   Tool callbacks from all sources are also **deduplicated by tool name**. Spring AI 2.0 added `ToolCallingChatOptions.validateToolCallbacks`, which rejects two tools with the same name — without the dedup, an endpoint combining `toolCallbacks` with a `toolNames` entry that names one of them fails with `Multiple tools with the same name`.
   
   ## Tests
   
   New `SpringAiChatToolNamesTest` covers name selection, the header override, the registry fallback, the duplicate-registration case and the unresolvable-name error. Existing tests were updated for `options()` vs `defaultOptions()`, the now-mandatory non-null `ChatModel.getOptions()`, Spring Framework 7 core retry, and the openai-java SDK client that `spring-ai-openai` is now built on.
   
   Verified against a local Ollama (`granite4:3b`, `embeddinggemma:300m`, `qwen3-vl:2b-instruct` for the multimodal IT):
   
   | Module | Result |
   |---|---|
   | chat | 91 tests pass (5 skipped — `SpringAiChatWrappedFileIT` is `@Disabled`) |
   | embeddings | 7 pass |
   | vector store | 16 pass, including the Qdrant testcontainers IT |
   | image | see below |
   
   `SpringAiImageOllamaIT` is the one I rewrote for the SDK change; its result is noted in a comment below.
   
   ## Upgrade notes
   
   `docs/.../camel-4x-upgrade-guide-4_22.adoc` gains a section covering the Jackson 3 move, the `.options.` property-key flattening, the removal of Spring AI's default `temperature=0.7`, and the `toolNames` change.
   
   ---
   _Claude Code on behalf of Federico Mariani_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24212: camel-spring-ai - upgrade to Spring AI 2.0 [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #25354:
URL: https://github.com/apache/camel/pull/25354#discussion_r3719765519


##########
components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/main/java/org/apache/camel/component/springai/chat/SpringAiChatProducer.java:
##########
@@ -994,6 +1005,49 @@ private List<ToolCallback> getToolCallbacksForTags(String tags) {
         return toolCallbacks;
     }
 
+    /**
+     * Resolve the configured tool names to {@link ToolCallback} instances.
+     * <p>
+     * Spring AI 2.0 removed {@code ChatClient.ChatClientRequestSpec.toolNames(String...)} and the Spring bean based
+     * {@code SpringBeanToolCallbackResolver}, so the names are resolved here instead. Each name is looked up, in order,
+     * against:
+     * <ol>
+     * <li>a {@link ToolCallbackResolver} bound in the Camel registry - Spring Boot applications get Spring AI's
+     * auto-configured resolver, which covers {@link ToolCallback} and {@link ToolCallbackProvider} beans</li>
+     * <li>the tool callbacks already available to this endpoint, i.e. the ones discovered from {@code tags} and the
+     * ones configured via {@code toolCallbacks}, matched on their tool definition name</li>
+     * <li>a {@link ToolCallback} bound in the Camel registry under that name</li>
+     * </ol>
+     *
+     * @param  names                    the tool names to resolve
+     * @param  availableByName          the callbacks already available to this endpoint, keyed by tool name
+     * @return                          the resolved callbacks, never {@code null}
+     * @throws IllegalArgumentException if a name cannot be resolved
+     */
+    private List<ToolCallback> resolveToolCallbacksByName(List<String> names, Map<String, ToolCallback> availableByName) {
+        final ToolCallbackResolver resolver = getEndpoint().getCamelContext().getRegistry()
+                .findSingleByType(ToolCallbackResolver.class);
+
+        final List<ToolCallback> resolved = new ArrayList<>(names.size());
+        for (String name : names) {
+            ToolCallback callback = resolver != null ? resolver.resolve(name) : null;

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24212: camel-spring-ai - upgrade to Spring AI 2.0 [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25354:
URL: https://github.com/apache/camel/pull/25354#issuecomment-5192554812

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `catalog/camel-catalog`
   - `components/camel-spring-parent/camel-spring-ai`
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat`
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-embeddings`
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-image`
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-vector-store`
   - `docs`
   - `dsl/camel-endpointdsl`
   - `parent`
   
   :white_check_mark: **POM dependency changes: targeted tests included**
   
   Changed properties: spring-ai-version
   
   <details><summary>Modules affected by dependency changes (1)</summary>
   
   - `:camel-spring-ai-parent`
   
   </details>
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 16 tested, 26 compile-only — current: 12 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **42 affected modules** (current approach: 12).
   
   <details><summary>:warning: Modules only in Scalpel (30)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog`
   - `camel-catalog-console`
   - `camel-catalog-lucene`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-csimple-maven-plugin`
   - `camel-endpointdsl`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-spring-ai-parent`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `docs`
   - `dummy-component`
   
   </details>
   
   Changed properties: spring-ai-version
   
   Changed managed dependencies: org.springframework.ai:spring-ai-bom
   
   **Skip-tests mode would test 16 modules** (8 direct + 8 downstream), **skip tests for 26** (generated code, meta-modules)
   
   <details><summary>Modules Scalpel would test (16)</summary>
   
   - `camel-catalog`
   - `camel-endpointdsl`
   - `camel-jbang-mcp`
   - `camel-jbang-plugin-mcp`
   - `camel-jbang-plugin-route-parser`
   - `camel-jbang-plugin-tui`
   - `camel-jbang-plugin-validate`
   - `camel-launcher-container`
   - `camel-spring-ai-chat`
   - `camel-spring-ai-embeddings`
   - `camel-spring-ai-image`
   - `camel-spring-ai-parent`
   - `camel-spring-ai-vector-store`
   - `camel-yaml-dsl-validator`
   - `camel-yaml-dsl-validator-maven-plugin`
   - `docs`
   
   </details>
   
   <details><summary>Modules with tests skipped (26)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog-console`
   - `camel-catalog-lucene`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-csimple-maven-plugin`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `dummy-component`
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   :warning: **Some tests are disabled on GitHub Actions** (`@DisabledIfSystemProperty(named = "ci.env.name")`) and require manual verification:
   
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat`: 21 test(s) disabled on GitHub Actions
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-embeddings`: 1 test(s) disabled on GitHub Actions
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-image`: 1 test(s) disabled on GitHub Actions
   - `components/camel-spring-parent/camel-spring-ai/camel-spring-ai-vector-store`: 1 test(s) disabled on GitHub Actions
   - `components/camel-spring-parent/camel-spring-ai`: 24 test(s) disabled on GitHub Actions
   
   <details><summary>All tested modules (42 modules)</summary>
   
   - Camel :: All Components Sync point
   - Camel :: Assembly
   - Camel :: Catalog :: CSimple Maven Plugin (deprecated)
   - Camel :: Catalog :: Camel Catalog
   - Camel :: Catalog :: Camel Report Maven Plugin
   - Camel :: Catalog :: Camel Route Parser
   - Camel :: Catalog :: Console
   - Camel :: Catalog :: Dummy Component
   - Camel :: Catalog :: Lucene (deprecated)
   - Camel :: Catalog :: Maven
   - Camel :: Catalog :: Suggest
   - Camel :: Component DSL
   - Camel :: Coverage
   - Camel :: Docs
   - Camel :: Endpoint DSL
   - Camel :: Endpoint DSL :: Support
   - Camel :: Integration Tests
   - Camel :: JBang :: Core
   - Camel :: JBang :: Integration tests
   - Camel :: JBang :: MCP
   - Camel :: JBang :: Main
   - Camel :: JBang :: Plugin :: Edit
   - Camel :: JBang :: Plugin :: Generate
   - Camel :: JBang :: Plugin :: Kubernetes
   - Camel :: JBang :: Plugin :: MCP
   - Camel :: JBang :: Plugin :: Route Parser
   - Camel :: JBang :: Plugin :: TUI
   - Camel :: JBang :: Plugin :: Testing
   - Camel :: JBang :: Plugin :: Validate
   - Camel :: Kamelet Main
   - Camel :: Launcher
   - Camel :: Launcher :: Container
   - Camel :: Spring AI :: Chat
   - Camel :: Spring AI :: Embeddings
   - Camel :: Spring AI :: Image
   - Camel :: Spring AI :: Parent
   - Camel :: Spring AI :: Vector Store
   - Camel :: YAML DSL
   - Camel :: YAML DSL :: Deserializers
   - Camel :: YAML DSL :: Maven Plugins
   - Camel :: YAML DSL :: Validator
   - Camel :: YAML DSL :: Validator Maven Plugin
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/31002953356)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24212: camel-spring-ai - upgrade to Spring AI 2.0 [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #25354:
URL: https://github.com/apache/camel/pull/25354#discussion_r3719723301


##########
components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/test/java/org/apache/camel/component/springai/chat/SpringAiChatToolNamesTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.springai.chat;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.springframework.ai.chat.messages.AssistantMessage;
+import org.springframework.ai.chat.model.ChatModel;
+import org.springframework.ai.chat.model.ChatResponse;
+import org.springframework.ai.chat.model.Generation;
+import org.springframework.ai.chat.prompt.ChatOptions;
+import org.springframework.ai.chat.prompt.Prompt;
+import org.springframework.ai.model.tool.ToolCallingChatOptions;
+import org.springframework.ai.tool.ToolCallback;
+import org.springframework.ai.tool.ToolCallbackProvider;
+import org.springframework.ai.tool.annotation.Tool;
+import org.springframework.ai.tool.method.MethodToolCallbackProvider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Unit test for selecting tools by name via the {@code toolNames} option and the
+ * {@link SpringAiChatConstants#TOOL_NAMES} header.
+ *
+ * Spring AI 2.0 removed {@code ChatClient.ChatClientRequestSpec.toolNames(String...)} and the Spring bean based
+ * {@code SpringBeanToolCallbackResolver}, so the component resolves the names itself. These tests capture the
+ * {@link Prompt} handed to the {@link ChatModel} and assert which tool callbacks made it through.
+ */
+public class SpringAiChatToolNamesTest extends CamelTestSupport {

Review Comment:
   Minor convention nit: since this is a **new** test file, the project guidelines ask for package-private visibility on the class and test methods (no `public` modifier). JUnit 5 doesn't require it.
   
   ```suggestion
   class SpringAiChatToolNamesTest extends CamelTestSupport {
   ```
   
   Same applies to the four `@Test` methods below (`public void` → `void`).



##########
components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/main/java/org/apache/camel/component/springai/chat/SpringAiChatProducer.java:
##########
@@ -994,6 +1005,49 @@ private List<ToolCallback> getToolCallbacksForTags(String tags) {
         return toolCallbacks;
     }
 
+    /**
+     * Resolve the configured tool names to {@link ToolCallback} instances.
+     * <p>
+     * Spring AI 2.0 removed {@code ChatClient.ChatClientRequestSpec.toolNames(String...)} and the Spring bean based
+     * {@code SpringBeanToolCallbackResolver}, so the names are resolved here instead. Each name is looked up, in order,
+     * against:
+     * <ol>
+     * <li>a {@link ToolCallbackResolver} bound in the Camel registry - Spring Boot applications get Spring AI's
+     * auto-configured resolver, which covers {@link ToolCallback} and {@link ToolCallbackProvider} beans</li>
+     * <li>the tool callbacks already available to this endpoint, i.e. the ones discovered from {@code tags} and the
+     * ones configured via {@code toolCallbacks}, matched on their tool definition name</li>
+     * <li>a {@link ToolCallback} bound in the Camel registry under that name</li>
+     * </ol>
+     *
+     * @param  names                    the tool names to resolve
+     * @param  availableByName          the callbacks already available to this endpoint, keyed by tool name
+     * @return                          the resolved callbacks, never {@code null}
+     * @throws IllegalArgumentException if a name cannot be resolved
+     */
+    private List<ToolCallback> resolveToolCallbacksByName(List<String> names, Map<String, ToolCallback> availableByName) {
+        final ToolCallbackResolver resolver = getEndpoint().getCamelContext().getRegistry()
+                .findSingleByType(ToolCallbackResolver.class);
+
+        final List<ToolCallback> resolved = new ArrayList<>(names.size());
+        for (String name : names) {
+            ToolCallback callback = resolver != null ? resolver.resolve(name) : null;

Review Comment:
   Question (non-blocking): if a third-party `ToolCallbackResolver` implementation throws instead of returning `null` for an unknown name, the fallback to `availableByName` / registry lookup is skipped. Spring AI's auto-configured resolver likely returns `null`, so this is probably fine — just flagging in case you've verified the contract.
   
   A defensive `try/catch` around `resolver.resolve(name)` could make the fallback chain more robust for custom resolvers, but I'd understand leaving it as-is for now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24212: camel-spring-ai - upgrade to Spring AI 2.0 [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25354:
URL: https://github.com/apache/camel/pull/25354#issuecomment-5191344965

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24212: camel-spring-ai - upgrade to Spring AI 2.0 [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway merged PR #25354:
URL: https://github.com/apache/camel/pull/25354


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24212: camel-spring-ai - upgrade to Spring AI 2.0 [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #25354:
URL: https://github.com/apache/camel/pull/25354#discussion_r3719750416


##########
components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/test/java/org/apache/camel/component/springai/chat/SpringAiChatToolNamesTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.springai.chat;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.springframework.ai.chat.messages.AssistantMessage;
+import org.springframework.ai.chat.model.ChatModel;
+import org.springframework.ai.chat.model.ChatResponse;
+import org.springframework.ai.chat.model.Generation;
+import org.springframework.ai.chat.prompt.ChatOptions;
+import org.springframework.ai.chat.prompt.Prompt;
+import org.springframework.ai.model.tool.ToolCallingChatOptions;
+import org.springframework.ai.tool.ToolCallback;
+import org.springframework.ai.tool.ToolCallbackProvider;
+import org.springframework.ai.tool.annotation.Tool;
+import org.springframework.ai.tool.method.MethodToolCallbackProvider;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Unit test for selecting tools by name via the {@code toolNames} option and the
+ * {@link SpringAiChatConstants#TOOL_NAMES} header.
+ *
+ * Spring AI 2.0 removed {@code ChatClient.ChatClientRequestSpec.toolNames(String...)} and the Spring bean based
+ * {@code SpringBeanToolCallbackResolver}, so the component resolves the names itself. These tests capture the
+ * {@link Prompt} handed to the {@link ChatModel} and assert which tool callbacks made it through.
+ */
+public class SpringAiChatToolNamesTest extends CamelTestSupport {

Review Comment:
   Fixed in ea39bdf — class and the four `@Test` methods are now package-private. The overrides (`doPreSetup`, `createRouteBuilder`, `configure`) keep the supertype visibility per the JLS 8.4.8.3 carve-out in AGENTS.md, and the `@Tool` holder classes stay `public` so Spring AI can reflect over them. Test still passes 4/4.
   
   _Claude Code on behalf of Federico Mariani_



##########
components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/main/java/org/apache/camel/component/springai/chat/SpringAiChatProducer.java:
##########
@@ -994,6 +1005,49 @@ private List<ToolCallback> getToolCallbacksForTags(String tags) {
         return toolCallbacks;
     }
 
+    /**
+     * Resolve the configured tool names to {@link ToolCallback} instances.
+     * <p>
+     * Spring AI 2.0 removed {@code ChatClient.ChatClientRequestSpec.toolNames(String...)} and the Spring bean based
+     * {@code SpringBeanToolCallbackResolver}, so the names are resolved here instead. Each name is looked up, in order,
+     * against:
+     * <ol>
+     * <li>a {@link ToolCallbackResolver} bound in the Camel registry - Spring Boot applications get Spring AI's
+     * auto-configured resolver, which covers {@link ToolCallback} and {@link ToolCallbackProvider} beans</li>
+     * <li>the tool callbacks already available to this endpoint, i.e. the ones discovered from {@code tags} and the
+     * ones configured via {@code toolCallbacks}, matched on their tool definition name</li>
+     * <li>a {@link ToolCallback} bound in the Camel registry under that name</li>
+     * </ol>
+     *
+     * @param  names                    the tool names to resolve
+     * @param  availableByName          the callbacks already available to this endpoint, keyed by tool name
+     * @return                          the resolved callbacks, never {@code null}
+     * @throws IllegalArgumentException if a name cannot be resolved
+     */
+    private List<ToolCallback> resolveToolCallbacksByName(List<String> names, Map<String, ToolCallback> availableByName) {
+        final ToolCallbackResolver resolver = getEndpoint().getCamelContext().getRegistry()
+                .findSingleByType(ToolCallbackResolver.class);
+
+        final List<ToolCallback> resolved = new ArrayList<>(names.size());
+        for (String name : names) {
+            ToolCallback callback = resolver != null ? resolver.resolve(name) : null;

Review Comment:
   Good catch to raise it — I did verify the contract, so I have left it as-is.
   
   `ToolCallbackResolver.resolve(String)` declares its return type as `@org.jspecify.annotations.Nullable` (visible as a `RuntimeVisibleTypeAnnotations` entry on the interface method in `spring-ai-model` 2.0.0), so returning `null` for an unknown name *is* the documented contract rather than an implementation detail. Spring AI 2.0 annotated the whole API surface with JSpecify, which is what makes this checkable now. `DelegatingToolCallbackResolver.resolve` iterates its delegates and returns `null` once none match, and `StaticToolCallbackResolver` returns `null` from its map lookup.
   
   I would rather not wrap it in a `try/catch`: a resolver that throws on an unknown name is violating the annotated contract, and swallowing that would turn a genuine misconfiguration (say a resolver whose backing service is unreachable) into a silent fallback to a different tool, or into the "Cannot resolve tool name" error further down, which would point at the wrong cause. Letting it propagate surfaces the real problem. Happy to revisit if a concrete third-party resolver turns up that throws.
   
   _Claude Code on behalf of Federico Mariani_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org