Skip to content

GH-5877: Use ToolExecutionEligibilityPredicate in ToolCallAdvisor for tool call detection#5878

Open
ArpanC6 wants to merge 1 commit intospring-projects:mainfrom
ArpanC6:GH-5877
Open

GH-5877: Use ToolExecutionEligibilityPredicate in ToolCallAdvisor for tool call detection#5878
ArpanC6 wants to merge 1 commit intospring-projects:mainfrom
ArpanC6:GH-5877

Conversation

@ArpanC6
Copy link
Copy Markdown

@ArpanC6 ArpanC6 commented Apr 24, 2026

What

We’ve made improvements to the ToolCallAdvisor by adding a ToolExecutionEligibilityPredicate. This new approach replaces the previous hardcoded chatResponse.hasToolCalls() check for detecting tool calls in both the non streaming (adviseCall) and streaming (handleToolCallRecursion) processes.

Additionally a toolExecutionEligibilityPredicate() method has been added to the Builder to allow users to inject a custom predicate if needed.

Why

Previously ToolCallAdvisor was using a hardcoded check (hasToolCalls()) to detect tool calls which didn't take into account more complex mechanisms used by models like Anthropic and Bedrock. These models rely on additional checks such as the finish reason (tool_use) to correctly detect tool calls. This made ToolCallAdvisor inconsistent with how other models handle tool call detection.

How

  1. We added a ToolExecutionEligibilityPredicate field to ToolCallAdvisor, which defaults to DefaultToolExecutionEligibilityPredicate.

  2. A new constructor was added to accept a custom predicate.

  3. We replaced the old chatResponse.hasToolCalls() check with toolExecutionEligibilityPredicate.isToolExecutionRequired() in both the non streaming and streaming tool call detection paths.

  4. We also added the toolExecutionEligibilityPredicate() method to the Builder allowing for easy customization.

This change addresses the issue and ensures that ToolCallAdvisor works seamlessly with different models that rely on custom tool call detection.

Closes #5877.

…CallAdvisor for tool call detection

Signed-off-by: Arpan Chakraborty <chakrabortyarpan151@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToolCallAdvisor uses hardcoded hasToolCalls() instead of ToolExecutionEligibilityPredicate for tool call detection

1 participant