fix(core): allow load_toolset strict success when all params are used - #735
fix(core): allow load_toolset strict success when all params are used#735hsusul wants to merge 1 commit into
Conversation
|
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. |
anubhav756
left a comment
There was a problem hiding this comment.
Can we also add tests for auth params as well just like in async client?
There was a problem hiding this comment.
Can we also add tests for auth params as well just like in async client?
| TOOL_P = "tool_with_p" | ||
| manifest = ManifestSchema( | ||
| serverVersion="0.0.0", | ||
| tools={TOOL_P: tool_schema_with_param_P}, |
There was a problem hiding this comment.
Can we have more than 1 tool here for better coverage?
|
/gcbrun |
9a11be6 to
aa55828
Compare
|
Updated! I've updated the strict=True test cases in both test_client.py and test_sync_client.py to include multiple tools in the toolset for better coverage, as well as added tests for auth parameters on the sync client. Thanks! |
aa55828 to
fb2c597
Compare
Accumulate used auth tokens and bound params under strict=True so the final toolset unused-requirement check no longer rejects valid loads.
fb2c597 to
28782f9
Compare
|
/gcbrun |
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)