Skip to content

fix: Toolset.add drops tools from lazy child toolsets#12020

Closed
shivanij1203 wants to merge 1 commit into
deepset-ai:mainfrom
shivanij1203:fix/toolset-add-lazy-warmup
Closed

fix: Toolset.add drops tools from lazy child toolsets#12020
shivanij1203 wants to merge 1 commit into
deepset-ai:mainfrom
shivanij1203:fix/toolset-add-lazy-warmup

Conversation

@shivanij1203

Copy link
Copy Markdown

Summary

Toolset.add() warmed the object being added only when the parent was already warmed up. For a lazily-loaded child Toolset (one that materializes its tools in warm_up()), adding it to a not-yet-warmed parent meant it was flattened with list(tool) while still empty, so its tools were silently dropped and a later parent.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: in Toolset.add(), warm a child Toolset before flattening it, regardless of the parent's warm-up state. Adding a plain Tool to 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 child Toolset to a cold parent (tools retained) and for duplicate-name validation against the materialized tools.
  • Release note under releasenotes/notes/.

Testing

  • test/tools/test_toolset.py — 33 passed (31 existing + 2 new).
  • Both new tests fail against the pre-fix code, so they guard the actual regression.
  • ruff format --check and ruff check pass on the changed files.

Reproduction from the issue, before the fix:

lazy = LazyToolset()      # builds its tool in warm_up()
parent = Toolset()        # not warmed
parent.add(lazy)
# {'lazy_warmups': 0, 'parent_tools': []}  -> tools dropped

After the fix the child is warmed before flattening, so parent contains the lazy tool.

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
shivanij1203 requested a review from a team as a code owner July 15, 2026 14:34
@shivanij1203
shivanij1203 requested review from davidsbatista and removed request for a team July 15, 2026 14:34
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@shivanij1203 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Jul 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sjrl

sjrl commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Closing as duplicate of #12012

@sjrl sjrl closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toolset.add() silently drops tools from lazy Toolsets before parent warm-up

3 participants