fix: warm child Toolset before flattening in Toolset.add()#12036
fix: warm child Toolset before flattening in Toolset.add()#12036mahesh-sadupalli wants to merge 1 commit into
Conversation
When a lazy Toolset (one that materialises its tools in warm_up()) was
added to a cold parent with add(), the guard on warm_up() was:
if self._is_warmed_up and hasattr(tool, 'warm_up'):
tool.warm_up()
So the child was never warmed before list(tool) flattened it. The
resulting list was empty and the tools were silently dropped.
Fix: warm every child Toolset before flattening unconditionally. The
child's warm_up() is idempotent, so calling it on an already-warm
child is safe. Plain Tool objects retain the existing behaviour: they
are only warmed immediately when the parent is already warm.
Three regression tests are added:
- lazy child added to cold parent retains its tools
- warm child added to warm parent is not warmed again (idempotency)
- plain Tool added to cold parent is still not warmed eagerly
Fixes: deepset-ai#12009
Signed-off-by: Mahesh Sadupalli <mahesh.sadupalli@gmail.com>
|
@mahesh-sadupalli is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
|
|
Hi @mahesh-sadupalli, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
|
Closing as duplicate of #12012 |
Fixes #12009
Summary
Toolset.add()silently dropped all tools when a lazy childToolset(one that materialises its tools inwarm_up()) was added to a parent that had not yet been warmed up.The guard was:
Because
self._is_warmed_upwasFalsefor a cold parent, the child was never warmed beforelist(tool)flattened it. The list was empty and the tools were silently lost — no exception raised.Fix: warm every child
Toolsetunconditionally before flattening. The child'swarm_up()is idempotent, so calling it on an already-warm child is safe. PlainToolobjects retain the existing behaviour: warmed immediately only when the parent is already warm.Tests
Three regression tests added to
TestToolsetWarmUp:test_add_lazy_toolset_to_cold_parent_retains_toolstest_add_lazy_toolset_warm_up_is_idempotenttest_add_plain_tool_to_cold_parent_does_not_warm_itTooladded to cold parent is still not warmed eagerlyAll 34 tests in
test/tools/test_toolset.pypass.