Skip to content

Commit 5b7849d

Browse files
committed
Add breaking changes to 1.0 M8 upgrade notes regarding chatclient tool calling
1 parent 6c52c99 commit 5b7849d

File tree

1 file changed

+67
-17
lines changed

1 file changed

+67
-17
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/upgrade-notes.adoc

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,80 @@ For details, refer to:
2525
- xref:upgrade-notes.adoc#common-package-changes[Common Package Changes]
2626
- xref:upgrade-notes.adoc#common-module-structure[Common Module Structure]
2727

28-
[[automating-upgrading-using-ai]]
29-
=== Automating upgrading using AI
28+
[[upgrading-to-1-0-0-m8]]
29+
== Upgrading to 1.0.0-M8
3030

31-
You can automate the upgrade process to 1.0.0-SNAPSHOT using the Claude Code CLI tool with a provided prompt. The prompt will guide the AI to perform the following tasks:
31+
You can automate the upgrade process to 1.0.0-M8 using an OpenRewrite recipe.
32+
This recipe helps apply many of the necessary code changes for this version.
33+
Find the recipe and usage instructions at https://github.com/arconia-io/arconia-migrations/blob/main/docs/spring-ai.md[Arconia Spring AI Migrations].
3234

33-
1. Update the Spring AI BOM version to 1.0.0-SNAPSHOT
34-
2. Ensure all required repositories exist in your build configuration
35-
3. Update Spring AI artifact IDs according to the new naming patterns
35+
=== Breaking Changes
36+
When upgrading from Spring AI 1.0 M7 to 1.0 M8, users who previously registered tool callbacks are encountering breaking changes that cause tool calling functionality to silently fail. This is specifically impacting code that used the deprecated `tools()` method.
3637

37-
To use this automation:
38+
==== Example
3839

39-
1. Download the https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview[Claude Code CLI tool]
40-
2. Copy the prompt from the https://github.com/spring-projects/spring-ai/blob/main/src/prompts/update-to-snapshot.txt[update-to-snapshot.txt] file
41-
3. Paste the prompt into the Claude Code CLI
42-
4. The AI will analyze your project and make the necessary changes
40+
Here's an example of code that worked in M7 but no longer functions as expected in M8:
4341

44-
This approach can save time and reduce the chance of errors when upgrading multiple projects or complex codebases.
42+
[source,java]
43+
----
44+
// Old code in M7 - no longer works correctly in M8
45+
chatClient.prompt("What day is tomorrow?")
46+
.tools(toolCallback)
47+
.call()
48+
.content();
49+
----
50+
51+
==== How to Adapt Your Code
52+
53+
To fix this issue when upgrading to M8, you need to update your code to use the new `toolCallbacks()` method:
54+
55+
[source,java]
56+
----
57+
// Updated code for M8
58+
chatClient.prompt("What day is tomorrow?")
59+
.toolCallbacks(toolCallback)
60+
.call()
61+
.content();
62+
----
63+
64+
==== Why This Change Was Made
65+
66+
The Spring AI team renamed the overloaded `tools()` methods to improve clarity and prevent ambiguity in method dispatching. The previous API design led to confusion when the Java compiler needed to select between multiple overloaded methods based on parameter types.
67+
68+
==== Method Mapping from M7 to M8
69+
70+
Here's how the old methods map to their new counterparts:
71+
72+
1. `tools(String... toolNames)` → `toolNames(String... toolNames)`
73+
- Use when referring to tools registered elsewhere (e.g., via `@Bean` with `@Description`)
74+
75+
2. `tools(ToolCallback... toolCallbacks)` → `toolCallbacks(ToolCallback... toolCallbacks)`
76+
- Use for inline tool callback registration
77+
78+
3. `tools(List<ToolCallback> toolCallbacks)` → `toolCallbacks(List<ToolCallback> toolCallbacks)`
79+
- Use when you have a collection of tool callbacks
80+
81+
4. `tools(ToolCallbackProvider... toolCallbackProviders)` → `toolCallbacks(ToolCallbackProvider... toolCallbackProviders)`
82+
- Use for objects implementing the `ToolCallbackProvider` interface
83+
84+
5. `tools(Object... toolObjects)` remains unchanged
85+
- Use only for objects with methods annotated with `@Tool`
86+
87+
==== Improved Error Handling
88+
89+
In the https://github.com/spring-projects/spring-ai/pull/2964[this PR now merged (spring-projects/spring-ai#2964)], the `tools(Object... toolObjects)` method will now throw an exception when no `@Tool` methods are found on the provided objects, rather than silently failing. This helps developers identify migration issues immediately.
90+
91+
==== Migration Summary
92+
93+
If you're upgrading from M7 to M8:
94+
95+
1. Replace all calls to `.tools(toolCallback)` with `.toolCallbacks(toolCallback)`
96+
2. Replace all calls to `.tools(toolCallbackProvider)` with `.toolCallbacks(toolCallbackProvider)`
97+
3. Replace all calls to `.tools("toolName")` with `.toolNames("toolName")`
98+
99+
These changes will ensure your tool calling functionality continues to work correctly after upgrading to Spring AI 1.0 M8.
45100

46-
[[upgrading-to-1-0-0-m8]]
47-
== Upgrading to 1.0.0-M8
48101

49-
You can automate the upgrade process to 1.0.0-M8 using an OpenRewrite recipe.
50-
This recipe helps apply many of the necessary code changes for this version.
51-
Find the recipe and usage instructions at https://github.com/arconia-io/arconia-migrations/blob/main/docs/spring-ai.md[Arconia Spring AI Migrations].
52102

53103
=== Chat Client
54104

0 commit comments

Comments
 (0)