test: guard ToolInvoker imports so chat-generator tests run under Haystack 3.0#3535
Merged
Conversation
Haystack 3.0 removes haystack.components.tools, so the module-level ToolInvoker import fails at test collection and hides every other test result in these chat-generator suites. Fall back to None on ImportError and skip the pipeline tests that need ToolInvoker. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Contributor
Contributor
Contributor
Contributor
Contributor
Contributor
Contributor
Contributor
Contributor
This was referenced Jul 2, 2026
bogdankostic
approved these changes
Jul 3, 2026
bogdankostic
left a comment
Contributor
There was a problem hiding this comment.
Looks good, failing orcarouter tests are unrelated.
sjrl
reviewed
Jul 3, 2026
Comment on lines
+422
to
423
| @pytest.mark.skipif(ToolInvoker is None, reason="ToolInvoker is not available in the installed haystack-ai version") | ||
| def test_pipeline_with_aimlapi_chat_generator(self, tools): |
Contributor
There was a problem hiding this comment.
@julian-risch I think it would have been better to replace this pipeline with one that uses an Agent such that it would run in both Haystack 2 and 3
Member
Author
There was a problem hiding this comment.
Create a follow up issue: https://github.com/deepset-ai/haystack-private/issues/452
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Haystack 3.0 removes
haystack.components.tools(ToolInvokerhas no drop-in replacement; tool execution moved into theAgent). In ten chat-generator test suites, the module-levelfrom haystack.components.tools import ToolInvokerfails. As a consequence, none of the tests are run.Proposed Changes:
For aimlapi, amazon_bedrock, cohere, cometapi, meta_llama, mistral, ollama, openrouter, orcarouter, togetherai:
try/except ImportErrorwith aToolInvoker = Nonefallback (as prototyped in try lifecycle Haystack branch #3467).@pytest.mark.skipif(ToolInvoker is None, ...)to the tests that actually useToolInvoker(one pipeline/live test per suite; two in ollama).How did you test it?
git+https://github.com/deepset-ai/haystack.git@v3into the test envs): all ten suites now collect and run. The failures this unmasks belong to the other known v3-incompatibility categories (lazy OpenAI client init and serialization changes).The failing tests are predominantly
test_init_*/test_from_dict_fail_wo_env_var(v3's lazy OpenAI client init — no client, and no API-key error, at__init__anymore),test_serde_in_pipeline/test_to_dict(v3 serialization format changes), and the asynctest_run_async*suites in mistral/openrouter (same lazy-client root cause). Those are tracked separately in the compatibility effort.cohere's
chat_generator.pyalso mentionshaystack.components.toolsin its docstring usage example — that is not a runtime import and is left for a follow-up that reworks the example for 3.0.Notes for the reviewer
The skipped-on-3.0 tests are integration/live pipeline tests that chain generator →
ToolInvoker. Once the 3.0 migration path for tool invocation in these examples is decided (e.g.Agent), they can be rewritten instead of skipped.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.🤖 Generated with Claude Code