-
Notifications
You must be signed in to change notification settings - Fork 199
Description
Background
In Haystack 2.19 we enhanced the tools parameter across all chat generators to accept Optional[Union[list[Union[Tool, Toolset]], Toolset]] (defined as ToolsType).
This enhancement allows users to:
- Pass a mixed list of
ToolandToolsetobjects - Pass a single
Toolsetobject directly - Combine multiple toolsets with standalone tools in the same list
Previous limitation: Components required either a list of Tool objects OR a single Toolset, but not both in the same list.
New capability: Users can now organize tools into logical Toolsets while also including standalone Tool objects, providing greater flexibility. For example:
generator = OpenAIChatGenerator(
tools=[math_toolset, weather_toolset, standalone_tool]
)This change is fully backward compatible and preserves structure during serialization/deserialization.
Required Changes
All chat generators in haystack-core-integrations that support tools need to be updated to use the new ToolsType format. Based on the current inventory, the following integrations need updates:
Generators with Tool Support
-
amazon-bedrock-haystack-AmazonBedrockChatGenerator -
anthropic-haystack-AnthropicChatGenerator -
cohere-haystack-CohereChatGenerator -
google-genai-haystack- Chat generators -
llama-cpp-haystack-LlamaCppChatGenerator -
llama-stack-haystack- Chat generators -
meta-llama-haystack- Chat generators -
mistral-haystack-MistralChatGenerator -
nvidia-haystack- Chat generators -
ollama-haystack-OllamaChatGenerator -
openrouter-haystack- Chat generators [ ]tools not supportedstackit-haystack- Chat generators-
togetherai-haystack- Chat generators [ ]tools not supportedwatsonx-haystack- Chat generators
Reference Implementation
See the Haystack core implementations for complete examples:
Testing Considerations
Each integration should add tests to verify:
- Accepting a list of
Toolobjects (existing behavior) - Accepting a single
Toolsetobject (existing behavior) - Accepting a mixed list of
ToolandToolsetobjects (new capability) - Proper serialization/deserialization of all three formats
- Detection of duplicate tool names across tools and toolsets
Acceptance Criteria
- All chat generators with tool support are updated to use
ToolsType - All affected integrations pass existing tests
- New tests added for mixed tools/toolsets functionality
- Documentation updated to reflect the new capability
- No breaking changes to existing APIs