Skip to content

fix(toolbox-core): Add strict flag support to sync client #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/toolbox-core/src/toolbox_core/sync_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def load_toolset(
name: str,
auth_token_getters: dict[str, Callable[[], str]] = {},
bound_params: Mapping[str, Union[Callable[[], Any], Any]] = {},
strict: bool = False,
) -> list[ToolboxSyncTool]:
"""
Synchronously fetches a toolset and loads all tools defined within it.
Expand All @@ -123,12 +124,22 @@ def load_toolset(
callables that return the corresponding authentication token.
bound_params: A mapping of parameter names to bind to specific values or
callables that are called to produce values as needed.
strict: If True, raises an error if *any* loaded tool instance fails
to utilize at least one provided parameter or auth token (if any
provided). If False (default), raises an error only if a
user-provided parameter or auth token cannot be applied to *any*
loaded tool across the set.

Returns:
list[ToolboxSyncTool]: A list of callables, one for each tool defined
in the toolset.

Raises:
ValueError: If validation fails based on the `strict` flag.
"""
coro = self.__async_client.load_toolset(name, auth_token_getters, bound_params)
coro = self.__async_client.load_toolset(
name, auth_token_getters, bound_params, strict
)

if not self.__loop or not self.__thread:
raise ValueError("Background loop or thread cannot be None.")
Expand Down