27 Commits

Author SHA1 Message Date
Stefano Fiorucci
8091034fb5
chore: remove unused imports and enforce related Ruff rule (#10278)
* chore: remove unused imports and enforce ruff rule

* fix

* enforce f401 rule

* pylint fix
2025-12-19 18:45:44 +01:00
Vladimir Blagojevic
ad5c242081
fix: Ensure ToolInvoker refreshes tool registry after warmup (#10171)
* Fix ToolInvoker refreshing tool registry after warmup for lazy-initialized toolsets

* PR feedback, convert integration to unit test
2025-12-02 10:25:16 +01:00
Vladimir Blagojevic
3ebe9b2df2
chore: Update default OpenAI model to gpt-5-mini (#10144)
* Update default OpenAI model to gpt-5-mini

* Update tests

* Fix tool invoker tests

* Update integration tests

* Update fragile test

* More robust tests

* Harden test

* More test improvements

* Better prompting, to trigger tools

* Simplify

* Simplify more

* Simplify even more, less maintenance in the future

* Mark two integration tests flaky

* Fixing fine details

* Add release note for OpenAI default model update to gpt-5-mini

* Add upgrade section to OpenAI default model release note
2025-12-01 13:55:53 +01:00
HamidOna
e7fb4f5ac5
fix: warm up individual tools inside Toolsets in warm_up_tools() (#10002)
* fix: warm up individual tools inside Toolsets in warm_up_tools()

Related Issues:

* Follows up on PR #9942 (feat: Add warm_up() method to ChatGenerators)

* Addresses bug discovered during implementation of PR #9942 for issue #9907

Proposed Changes:

The warm_up_tools() utility function was only calling warm_up() on

Toolset objects themselves, but not on the individual Tool instances

contained within them. This meant tools inside a Toolset were not

properly initialized before use.

This PR modifies warm_up_tools() to iterate through Toolsets and call

warm_up() on each individual tool, in addition to calling warm_up() on

the Toolset itself.

Changes:

- Modified warm_up_tools() in haystack/tools/utils.py to iterate through

  Toolsets when encountered (both as single argument and within lists)

- Added iteration to call warm_up() on each individual Tool inside Toolsets

- Added comprehensive test class TestWarmUpTools with 7 test cases

How did you test it:

- Added 7 comprehensive unit tests in test/tools/test_tools_utils.py:

  * test_warm_up_tools_with_none - handles None input

  * test_warm_up_tools_with_single_tool - single tool in list

  * test_warm_up_tools_with_single_toolset - KEY TEST: verifies both

    Toolset and individual tools are warmed

  * test_warm_up_tools_with_list_containing_toolset - toolset within list

  * test_warm_up_tools_with_multiple_toolsets - multiple toolsets

  * test_warm_up_tools_with_mixed_tools_and_toolsets - mixed scenarios

  * test_warm_up_tools_idempotency - safe to call multiple times

Notes for the reviewer:

I discovered this bug while implementing PR #9942 (for issue #9907).

When a Toolset object is passed to a component's tools parameter, the

warm_up_tools() function only calls Toolset.warm_up(), which is a no-op.

It doesn't iterate through the individual tools inside the Toolset to

warm them up.

 acknowledged by @vblagoje and @sjrl

This implementation:

- Modified warm_up_tools() to iterate through Toolsets and call warm_up() on each individual tool

 - Added comprehensive tests for Toolset warming behavior

- Verified both the Toolset and its contained tools are warmed up

Checklist:

I have read the contributors guidelines and the code of conduct

I have updated the related issue with new insights and changes

I added unit tests and updated the docstrings

I've used one of the conventional commit types for my PR title: fix:

I documented my code

I ran pre-commit hooks and fixed any issue

* added release note

* refactor: move tool warm-up iteration to Toolset.warm_up()

Addresses architectural feedback - moved iteration logic from warm_up_tools()
to base Toolset.warm_up() for better encapsulation. Subclasses can now
override warm_up() to customize initialization without breaking the contract.

- Toolset.warm_up() now iterates and warms tools by default
- warm_up_tools() simplified to delegate to warm_up()
- Updated tests and release notes

---------

Co-authored-by: HamidOna13 <abdulhamid.onawole@aizatron.com>
2025-11-05 09:59:23 +01:00
Vladimir Blagojevic
9bc59c3806
Add Tools warm_up (#9856)
* Tools warmup initial

* Fix lint

* Improve pydocs for warm_up

* Further improve pydocs for warm_up

* No need to warm_up tools in Agent as they are warmed up by ToolInvoker

* Simplify Toolset __add__ logic

* Simplify _ToolsetWrapper

* Add unit tests

* ToolInvoker warm_up

* Improve Tool pydoc

* Resurrect serde_utils.py

* Update tests

* Call ToolInvoker warm_up in agent warm_up

* Lint

* Move warm_up tests to ToolInvoker

* Update tests

* Remove tests

* Pydoc nit

* PR feedback

* ToolInvoker's warm_up is idempotent

* Add reno note

* Update releasenotes/notes/tools-warm-up-support-e16cc043fed3653f.yaml

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>

* Make ComponentTool warm_up idempotent

* Update warm_up_tools to use ToolsType

* Linting

* Add warm up test for mixed list of Tool/Toolset instances

---------

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
2025-10-20 12:11:34 +02:00
Sebastian Husch Lee
7f802656f6
chore: Refactor tool invoker (#9794)
* Refactoring tool invoker

* More refactoring

* More refactoring

* Small fix

* Fix

* max_workers was missing from ToolInvoker.to_dict
2025-09-22 09:39:52 +02:00
Stefano Fiorucci
8160ea8bfc
feat: ToolInvoker - pass tools in run + general refactoring (#9704)
* draft

* more refactoring

* fixes

* tools in run + tests

* reorganize tests

* refinements

* relnote

* log overridden tools

* more static methods
2025-08-13 10:10:30 +02:00
Sebastian Husch Lee
85258f0654
fix: Fix types and formatting pipeline test_run.py (#9575)
* Fix types in test_run.py

* Get test_run.py to pass fmt-check

* Add test_run to mypy checks

* Update test folder to pass ruff linting

* Fix merge

* Fix HF tests

* Fix hf test

* Try to fix tests

* Another attempt

* minor fix

* fix SentenceTransformersDiversityRanker

* skip integrations tests due to model unavailable on HF inference

---------

Co-authored-by: anakin87 <stefanofiorucci@gmail.com>
2025-07-03 09:49:09 +02:00
Amna Mubashar
9fd552f906
chore: remove deprecated async_executor param from ToolInvoker (#9571)
* Remove async executor

* Add release notes

* Linting

* update release notes
2025-07-02 14:02:51 +02:00
Amna Mubashar
adb2759d00
chore: remove deprecated State from haystack.dataclasses (#9578)
* Remove deprecated class

* Remove state from pydocs
2025-07-02 12:19:06 +02:00
Amna Mubashar
f11870b212
fix: adjust the async executor in ToolInvoker (#9562)
* Fix bug

* Add a new test

* PR comments

* Add another test

* Small fix

* Fix linting

* Update tests
2025-06-30 15:13:01 +02:00
Amna Mubashar
1cd0a128d0
feat: enable parallel tool execution in ToolInvoker (#9530)
* Enable parallel tool execution in ToolInvoker

* Update handling of errors

* Small fixes

* Small fixes

* Adapt number of executors

* Add release notes

* Add parallel tool calling to sync run

* Deprecate async_executor

* Deprecate async_executor

* Add thread lock

* extract methods

* Update release notes

* Update release notes

* Updates

* Add new tests

* Add test for async

* PR comments
2025-06-25 13:32:11 +02:00
Vladimir Blagojevic
91094e1038
feat: Add finish_reason field to StreamingChunk (#9536)
* Initial commit

* Update deprecation version

* Improve comment

* Minor simplification

* Add reno note

* Remove deprecation warning

* Remove fallback in haystack/components/generators/utils.py

* FinishReason alphabetical import

* Add tool_call_results finish reason, adapt codebase

* Define finish_reason to be Optional[FinishReason]

* Add StreamingChunk finish_reason in HF generators

* Update reno note

* Repair merge issue

* Update tests for finish_reason

* Resolve mypy issues

* Lint issue

* Enhance HF finish_reason translation

* Remove irrlevant test

* PR comments

---------

Co-authored-by: Sebastian Husch Lee <sjrl423@gmail.com>
2025-06-25 09:06:01 +00:00
Sebastian Husch Lee
a1484cb91c
Add unit test (#9519) 2025-06-16 13:14:02 +02:00
Sebastian Husch Lee
54c5057e0b
feat: (and fix) Add enable_streaming_passthrough to ToolInvoker and add missing params to to_dict (#9498)
* Fixes and tests

* Add reno

* Change variable name

* Add test and fix for passing streaming_callback to a component tool

* Add unit test

* Remove unused import

* Fix reno
2025-06-06 14:16:05 +02:00
David S. Batista
da60156174
chore: removing unused imports from tests (#9446) 2025-05-26 16:22:51 +00:00
Amna Mubashar
995fa18607
feat: stream ToolResult from run_async in Agent (#9407)
* Add async run

* Add release notes

* Update the run async

* Fixes

* Fix linting

* Add tests

* Fix tests

* Remove changes from Tool

* Linting updates

* Update haystack/components/tools/tool_invoker.py

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>

* Updates tests based on comments

* Update release notes

---------

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
2025-05-21 10:22:38 +02:00
Sebastian Husch Lee
707573d967
feat: Streamline using Agent as a ComponentTool (#9388)
* Make agent as a tool more streamlined

* Add reno

* fix mypy
2025-05-16 13:11:43 +02:00
Amna Mubashar
64f384b52d
feat: enable streaming ToolCall/Result from Agent (#9290)
* Testing solutions for streaming

* Remove unused methods

* Add fixes

* Update docstrings

* add release notes and test

* PR comments

* add a new util function

* Adjust emit_tool_info

* PR comments

* Remove emit function, add streaming for tool_call


---------

Co-authored-by: Sebastian Husch Lee <sjrl423@gmail.com>
2025-05-05 16:23:44 +02:00
Sebastian Husch Lee
d5ae46bc93
feat: Add Toolset to Agent (#9284)
* Add Toolset to Agent

* Add reno
2025-04-22 14:08:34 +02:00
Amna Mubashar
498637788a
feat: Allow OpenAI client config in OpenAIChatGenerator and AzureOpenAIChatGenerator (#9215)
* Allow OpenAI client config in chat generator

* Add init_http_client as a util method

* Update azure chat gen

* Fix linting
2025-04-16 18:32:13 +02:00
Sebastian Husch Lee
d15f1b9043
feat: Add outputs_to_string to Tool and ComponentTool (#9152)
* Add outputs_to_string to Tool and ComponentTool

* Doc string and fix tests

* Add reno

* Fix mypy
2025-04-01 14:04:50 +02:00
Julian Risch
657d09d7f1
feat: integrate updates of Tool, ToolInvoker, State, create_tool_from_function, ComponentTool from haystack-experimental (#9113)
* update Tool,ToolInvoker,ComponentTool,create_tool_from_function

* add State and its utils

* add tests for State and its utils

* update tests for Tool etc.

* reno

* fix circular imports

* update experimental imports in tests

* fix unit tests

* fix ChatGenerator unit tests

* mypy

* add State to init and pydoc

* explain State in more detail in release note

* add test from #8913

* re-add _check_duplicate_tool_names and refactor imports

* rename inputs and outputs
2025-03-28 10:49:23 +01:00
Sebastian Husch Lee
296e31c182
feat: Add Type Validation parameter for Pipeline Connections (#8875)
* Starting to refactor type util tests to be more systematic

* refactoring

* Expand tests

* Update to type utils

* Add missing subclass check

* Expand and refactor tests, introduce type_validation Literal

* More test refactoring

* Test refactoring, adding type validation variable to pipeline base

* Update relaxed version of type checking to pass all newly added tests

* trim whitespace

* Add tests

* cleanup

* Updates docstrings

* Add reno

* docs

* Fix mypy and add docstrings

* Changes based on advice from Tobi

* Remove unused imports

* Doc strings

* Add connection type validation to to_dict and from_dict

* Update tests

* Fix test

* Also save connection_type_validation at global pipeline level

* Fix tests

* Remove connection type validation from the connect level, only keep at pipeline level

* Formatting

* Fix tests

* formatting
2025-03-03 16:00:22 +01:00
Stefano Fiorucci
3f15f38c51
refactor: move Tool to a separate package; refactor serde (#8690)
* move tool to separate package; refactor serde

* release note

* rm unused import
2025-01-09 12:30:13 +01:00
Stefano Fiorucci
188b2a7f06
feat: support for tools in OpenAIChatGenerator (#8666)
* move chatmsg>openai conversion to chatmsg dataclass

* implementation and tests cleanup

* release note

* try fixing azure chat generator

* add serde test for toolinvoker

* small fix
2024-12-20 14:20:54 +00:00
Stefano Fiorucci
7dcbf25bd7
feat: add Tool Invoker component (#8664)
* port toolinvoker

* release note
2024-12-20 14:02:42 +01:00