Skip to content

feat: Implement strict validation for client while loading tools #205

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

Open
wants to merge 6 commits into
base: anubhav-fix-used-params
Choose a base branch
from

Conversation

anubhav756
Copy link
Contributor

@anubhav756 anubhav756 commented May 1, 2025

This pull request introduces a strict mode to the load_toolset method and refines the validation behavior of the load_tool method.

Benefits

  • Ensures tools are configured as intended and are using all provided authentication mechanisms and parameters.
  • Helps identify misconfigurations or unused inputs during the tool loading phase, rather than leading to potential runtime issues.
  • Makes it explicit when a tool is not interacting with expected configurations.

Changes

load_toolset(strict: bool = False)

The load_toolset method now includes an optional strict flag:

  • strict = False (Default Behavior):

    • Validation will fail (raising a ValueError) if at least one authentication token getter (from the auth_token_getters provided) or at least one bound parameter (from the bound_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:

    • Validation becomes significantly more stringent on a per-tool basis. The method will fail if any individual tool loaded within the toolset does not utilize all of the globally provided authentication token getters and all of the globally provided bound parameters.
    • This mode ensures that every tool explicitly engages with every piece of shared configuration passed during the load_toolset call.

load_tool()

  • The strict flag has been intentionally omitted from the load_tool method.
  • The validation for 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.
  • This decision was made because load_tool processes only one tool at a time. In this context, the nuanced behaviors of strict = True versus strict = False (as defined for load_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 and used_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 in load_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.

@anubhav756 anubhav756 self-assigned this May 1, 2025
@anubhav756 anubhav756 force-pushed the anubhav-fix-used-params branch from e5763b9 to be9ec4b Compare May 2, 2025 13:34
@anubhav756 anubhav756 marked this pull request as ready for review May 2, 2025 14:33
@anubhav756 anubhav756 requested a review from a team as a code owner May 2, 2025 14:33
@anubhav756 anubhav756 force-pushed the anubhav-fix-used-params branch from be9ec4b to 2e36f66 Compare May 5, 2025 08:25
@anubhav756 anubhav756 force-pushed the anubhav-fix-used-params branch from 2e36f66 to ea1a66b Compare May 5, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant