Skip to content

Commit d44724d

Browse files
committed
fix(toolbox-core): Prevent rebinding of parameters in ToolboxTool
This pull request updates the `bind_parameters` helper function within the `ToolboxTool` of the `toolbox-core` package to enhance parameter binding management. * The helper now throws an explicit error if a user attempts to bind a parameter that has already been bound. This change aims to prevent unexpected behavior and improve the clarity of parameter assignments. * The error that previously occurred when a user tried to bind a parameter not present in the tool's schema has been removed. This validation will be handled by a `strict` mode implementation in a future PR.
1 parent 0ff650a commit d44724d

File tree

1 file changed

+4
-3
lines changed
  • packages/toolbox-core/src/toolbox_core

1 file changed

+4
-3
lines changed

packages/toolbox-core/src/toolbox_core/tool.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,11 @@ def bind_parameters(
286286
Returns:
287287
A new ToolboxTool instance with the specified parameters bound.
288288
"""
289-
param_names = set(p.name for p in self.__params)
290289
for name in bound_params.keys():
291-
if name not in param_names:
292-
raise Exception(f"unable to bind parameters: no parameter named {name}")
290+
if name in self.__bound_parameters:
291+
raise ValueError(
292+
f"cannot re-bind parameter: parameter '{name}' is already bound"
293+
)
293294

294295
new_params = []
295296
for p in self.__params:

0 commit comments

Comments
 (0)