fix: Toolset.add drops tools from lazy child toolsets#12020
Closed
shivanij1203 wants to merge 1 commit into
Closed
fix: Toolset.add drops tools from lazy child toolsets#12020shivanij1203 wants to merge 1 commit into
shivanij1203 wants to merge 1 commit into
Conversation
Adding a lazy child toolset (one that builds its tools in warm_up) to a toolset that hasn't been warmed yet flattened it to an empty list, so its tools were lost. Warm the child before flattening. Closes deepset-ai#12009.
|
@shivanij1203 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Closing as duplicate of #12012 |
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.
Summary
Toolset.add()warmed the object being added only when the parent was already warmed up. For a lazily-loaded childToolset(one that materializes its tools inwarm_up()), adding it to a not-yet-warmed parent meant it was flattened withlist(tool)while still empty, so its tools were silently dropped and a laterparent.warm_up()could not recover them. This contradicts the method's own comment about warming the source before flattening.Fixes #12009
Changes
haystack/tools/toolset.py: inToolset.add(), warm a childToolsetbefore flattening it, regardless of the parent's warm-up state. Adding a plainToolto a cold parent is unchanged (still warmed only when the parent is warmed up).test/tools/test_toolset.py: regression tests for adding a lazy childToolsetto a cold parent (tools retained) and for duplicate-name validation against the materialized tools.releasenotes/notes/.Testing
test/tools/test_toolset.py— 33 passed (31 existing + 2 new).ruff format --checkandruff checkpass on the changed files.Reproduction from the issue, before the fix:
After the fix the child is warmed before flattening, so
parentcontains the lazy tool.