Skip to content

docs: Update docstring for strict flag to make it unambiguous #247

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 1 commit into from
May 19, 2025

Conversation

anubhav756
Copy link
Contributor

@anubhav756 anubhav756 commented May 19, 2025

The previous docstring for the strict parameter in the load_toolset method could be interpreted ambiguously. This change clarifies that when strict=True, an error is raised if any loaded tool instance fails to utilize all of the applicable parameters or auth tokens that were provided globally to load_toolset.

The original phrasing "fails to utilize at least one provided parameter" could have been misconstrued to mean an error only occurs if a tool uses none of the provided parameters. The updated phrasing "fails to utilize all of the given parameters or auth tokens" more accurately reflects the implemented behavior: each tool must exhaustively use all relevant configurations passed to load_toolset when in strict mode.

Note

Note that neither strict=False nor strict=True mode in load_toolset will inherently identify a tool within the set that is loaded but does not (and perhaps is not intended to) utilize any of the globally provided auth_token_getters or bound_params.

For instance, if a user wishes to validate the presence or specific configuration of such a "passively" configured tool (i.e., one that doesn't consume any of the globally provided configurations during the load_toolset call), a different approach is needed. In this scenario, the user would need to iterate through the tools individually after they are loaded and use methods like add_auth_token_getters() and/or bind_params() on a per-tool basis. This allows for checks of compatibility (e.g., whether a specific tool can accept a certain auth token or bound parameter, which would raise a ValueError if it's an unknown or inapplicable configuration for that particular tool) or to confirm expected behavior when such configurations are applied post-loading.

Eg.

tool = client.load_tool("my-passive-tool")

for auth_src, auth_token_getter in auth_token_getters.items():
    try:
        tool.add_auth_token_getter(auth_src, auth_token_getter)
    except ValueError as e:
        # tool did not use auth_src

@anubhav756 anubhav756 self-assigned this May 19, 2025
@anubhav756 anubhav756 requested a review from a team as a code owner May 19, 2025 15:40
@anubhav756 anubhav756 merged commit 59f0634 into main May 19, 2025
20 checks passed
@anubhav756 anubhav756 deleted the anubhav-strict-doc branch May 19, 2025 15:54
@release-please release-please bot mentioned this pull request May 19, 2025
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.

2 participants