feat: Implement strict validation for client while loading tools #205
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.
This pull request introduces a
strict
mode to theload_toolset
method and refines the validation behavior of theload_tool
method.Benefits
Changes
load_toolset(strict: bool = False)
The
load_toolset
method now includes an optionalstrict
flag:strict = False
(Default Behavior):ValueError
) if at least one authentication token getter (from theauth_token_getters
provided) or at least one bound parameter (from thebound_params
provided) is not utilized by any of the tools loaded within the toolset. This ensures that all globally provided configurations find a consumer within the set.strict = True
:load_toolset
call.load_tool()
strict
flag has been intentionally omitted from theload_tool
method.load_tool
is now standardized to be inherently strict: the single loaded tool must utilize all provided auth token getters and all provided bound parameters.load_tool
processes only one tool at a time. In this context, the nuanced behaviors ofstrict = True
versusstrict = False
(as defined forload_toolset
) do not apply; the expectation for a single tool is always full utilization of its provided configurations.Implementation
The validation logic leverages the
used_auth_keys
andused_bound_keys
values returned by the internal__parse_tool
helper function. This information indicates which specific auth token getters and bound parameters are actively used by each processed tool.Note
The
strict
flag available inload_toolset
is a runtime parameter that governs the validation behavior during the loading process. It is not persisted as part of the tool's loaded configuration or state.This is because at the level of an individual tool's direct configuration (e.g., if one were to add an auth token getter directly to a single tool instance), the "strictness" is inherent: that single tool would naturally be expected to use the configuration specifically provided to it. This aligns with the always-strict validation now enforced by the
load_tool
method.