fix(core): allow load_toolset strict success when all params are used#735
Open
hsusul wants to merge 1 commit into
Open
fix(core): allow load_toolset strict success when all params are used#735hsusul wants to merge 1 commit into
hsusul wants to merge 1 commit into
Conversation
Accumulate used auth tokens and bound params under strict=True so the final toolset unused-requirement check no longer rejects valid loads.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ToolboxClient.load_toolset(..., strict=True)incorrectly rejecting loads where every provided auth token / bound parameter is used by every tool.strict=True.🛠️ Fixes #734
Problem
With a mocked toolset containing a single tool that declares
param_P:Before: raised
even though the tool used
param_P. The same false failure occurred for fully used auth token getters.After: loading succeeds, matching the
strictdocstring (fail only when any tool fails to use all provided params/tokens).No GitHub issue was required for permissions reasons beyond standard contribution flow; issue #734 was filed to satisfy the PR template's issue-first checklist.
Root cause
In
ToolboxClient.load_toolset, per-tool usage was recorded only in theelse(non-strict) branch:Under
strict=True,overall_used_*stayed empty, so the final toolset check treated every provided key as unused.Minimal implementation
Always update
overall_used_auth_keys/overall_used_bound_params, then still run the per-tool strict check. Non-strict semantics are unchanged. Sync client inherits the fix viaToolboxSyncClient.load_toolset.Tests
test_load_toolset_strict_with_fully_used_bound_param_successtest_load_toolset_strict_with_fully_used_auth_successtest_sync_load_toolset_strict_with_fully_used_bound_param_successValidation
From
packages/toolbox-corewithpip install -e .[test](Python 3.12):python -m pytest tests/test_client.py::TestValidation tests/test_sync_client.py::test_sync_load_toolset_strict_with_fully_used_bound_param_success -v→ 9 passedpython -m pytest tests/ --ignore=tests/test_e2e.py --ignore=tests/test_sync_e2e.py --ignore=tests/test_e2e_mcp.py --ignore=tests/conformance -q --cov=src/toolbox_core --cov-fail-under=90→ 478 passed, coverage 91.74%black --check .→ passisort --check .→ passMYPYPATH='./src' mypy --install-types --non-interactive -p toolbox_core→ passgit diff --check→ passLive Toolbox / GCP integration tests were not run (mocked unit coverage is sufficient for this client validation bug).
Adapter compatibility
No adapter changes. LangChain / LlamaIndex / ADK call into the same core
load_toolsetpath and inherit the corrected strict behavior.Non-goals
isErrorhandling, schema conversion, or ADK auth lifecycle (separate candidates)Test plan
black,isort) andmypyfortoolbox_coretests: runlabel //gcbrunif needed for fork PRs)