Skip to content

fix(core): allow tool callbacks and providers directly in ChatClient tools()#6263

Closed
Baqirrizvidev wants to merge 1 commit into
spring-projects:mainfrom
Baqirrizvidev:fix/chat-client-tools-providers
Closed

fix(core): allow tool callbacks and providers directly in ChatClient tools()#6263
Baqirrizvidev wants to merge 1 commit into
spring-projects:mainfrom
Baqirrizvidev:fix/chat-client-tools-providers

Conversation

@Baqirrizvidev
Copy link
Copy Markdown
Contributor

Resolves #6206. Permitting ChatClient.prompt().tools(...) to accept ToolCallback, ToolCallbackProvider, collections, and arrays of them directly, matching user expectations after deprecation of toolCallbacks(...).

@sdeleuze
Copy link
Copy Markdown
Contributor

sdeleuze commented Jun 3, 2026

Superseded by #6275.

@sdeleuze sdeleuze closed this Jun 3, 2026
@sdeleuze
Copy link
Copy Markdown
Contributor

sdeleuze commented Jun 3, 2026

After discussing with @tzolov and @ilayaperumalg, we are considering this approach so let's reopen it.

@sdeleuze sdeleuze reopened this Jun 3, 2026
@tzolov tzolov added this to the 2.0.0-RC1 milestone Jun 4, 2026
@tzolov tzolov added enhancement New feature or request tool calling labels Jun 4, 2026
tzolov added a commit that referenced this pull request Jun 4, 2026
ChatClientRequestSpec.tools(Object...) now routes ToolCallback and
ToolCallbackProvider instances directly to their respective lists
instead of passing them to ToolCallbacks.from(), with null-element
guards added for array and Collection arguments.

Simplify all call sites from .tools(t -> t.callbacks(X)) to .tools(X)
and update docs accordingly.

See #6206

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
@tzolov
Copy link
Copy Markdown
Contributor

tzolov commented Jun 4, 2026

rebased, extended, squashed and merged at 699ad98

@tzolov tzolov closed this Jun 4, 2026
tzolov added a commit to tzolov/spring-ai that referenced this pull request Jun 4, 2026
Follow-up to spring-projects#6263: now that tools(Object...) accepts ToolCallback and
ToolCallbackProvider directly, the ToolSpec consumer overloads are no longer
needed. Remove tools(Consumer<ToolSpec>), defaultTools(Consumer<ToolSpec>),
and the ChatClient.ToolSpec interface entirely.

toolContext() and defaultToolContext() are promoted to first-class non-deprecated
methods with full key/value validation. mutate() is fixed to propagate
toolCallbackProviders and toolContext to the cloned builder.

Align tests and docs with IllegalArgumentException change in MethodToolCallbackProvider

Update docs and tests accordingly.

See spring-projects#6206

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
tzolov added a commit to tzolov/spring-ai that referenced this pull request Jun 4, 2026
Follow-up to spring-projects#6263: now that tools(Object...) accepts ToolCallback and
ToolCallbackProvider directly, the ToolSpec consumer overloads are no longer
needed. Remove tools(Consumer<ToolSpec>), defaultTools(Consumer<ToolSpec>),
and the ChatClient.ToolSpec interface entirely.

toolContext() and defaultToolContext() are promoted to first-class non-deprecated
methods with full key/value validation. mutate() is fixed to propagate
toolCallbackProviders and toolContext to the cloned builder.

Align tests and docs with IllegalArgumentException change in MethodToolCallbackProvider

Update docs and tests accordingly.

See spring-projects#6206

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
tzolov added a commit that referenced this pull request Jun 4, 2026
Follow-up to #6263: now that tools(Object...) accepts ToolCallback and
ToolCallbackProvider directly, the ToolSpec consumer overloads are no longer
needed. Remove tools(Consumer<ToolSpec>), defaultTools(Consumer<ToolSpec>),
and the ChatClient.ToolSpec interface entirely.

toolContext() and defaultToolContext() are promoted to first-class non-deprecated
methods with full key/value validation. mutate() is fixed to propagate
toolCallbackProviders and toolContext to the cloned builder.

Align tests and docs with IllegalArgumentException change in MethodToolCallbackProvider

Update docs and tests accordingly.

See #6206

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tool calling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecated method toolCallbacks cannot be replaced with method tools when using mcp client

3 participants