fix(delegate): keep child credential pools provider-scoped - #58337
fix(delegate): keep child credential pools provider-scoped#58337izumi0uu wants to merge 1 commit into
Conversation
Duplicate of #39862 (earliest open) — both add a provider-match guard to |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the post-construction pool attachment and the lease/swap path; current main still has the reported mismatch path at tools/delegate_tool.py:3023 and :1770.
Problems
- The new helper accepts every
custom:*pool when the child provider iscustom(tools/delegate_tool.py:3011). That does not preserve the endpoint boundary: a child at endpoint A can still lease acustom:endpoint-bpool and have_swap_credentialreplace its endpoint/key. Main already has the endpoint-aware contract inagent/credential_pool.py:464-499, with coverage intests/agent/test_credential_pool_provider_boundary.py:16-26.
Suggested changes
- Reuse
credential_pool_matches_provider, passingeffective_base_urlin the resolver andchild.base_urlin_run_single_child. - Add resolver and lease-path tests for
customendpoint A versus acustom:endpoint-bpool.
Automated hermes-sweeper review.
| provider = provider.strip().lower() | ||
| if pool_provider == provider: | ||
| return True | ||
| return provider == "custom" and pool_provider.startswith("custom:") |
There was a problem hiding this comment.
This accepts any custom:* pool for a custom child, including a pool for a different endpoint. Please reuse agent.credential_pool.credential_pool_matches_provider and pass the runtime base URL; its custom-provider branch verifies the exact custom:<name> key.
Delegated agents can intentionally use a provider/model different from the parent, but a reused parent credential pool was able to lease a credential for another concrete provider and swap the child's runtime back to that pool's provider. Keep same-provider sharing intact while refusing concrete pool/provider mismatches before resolution and leasing.\n\nConstraint: Same-provider credential pool sharing must keep cooldown and rotation state synchronized for delegated agents.\nRejected: Disable child credential leasing entirely | would regress valid same-provider rotation and custom-provider pooling.\nConfidence: high\nScope-risk: narrow\nDirective: Do not reintroduce parent pool reuse unless the pool provider matches the child provider or the same custom endpoint identity.\nTested: python -m compileall -q tools/delegate_tool.py tests/tools/test_delegate.py; scripts/run_tests.sh tests/tools/test_delegate.py -q; scripts/run_tests.sh tests/agent/test_credential_pool_routing.py tests/run_agent/test_fallback_credential_isolation.py -q; manual after-fix resolver probe for deepseek child with zai parent pool.\nNot-tested: Full pytest suite.
e542739 to
bdbb94d
Compare
|
Addressed in bdbb94d. I replaced the local matching helper with I also added resolver and lease-path regressions for a child on custom |
What does this PR do?
Fixes delegated subagents accidentally reusing a parent credential pool whose concrete provider does not match the delegated child provider. When delegation is configured for a different provider/model, a mismatched pool lease can call
_swap_credential()and overwrite the child runtime back to the pool provider.This keeps same-provider pool sharing intact for cooldown/rotation state, but refuses concrete provider mismatches before pool resolution and before child leasing.
Related Issue
Fixes #58298
Type of Change
Changes Made
tools/delegate_tool.py: add a provider-match guard for child credential pools and apply it when resolving parent pool reuse and when leasing in_run_single_child().tests/tools/test_delegate.py: cover rejecting a mismatched parent pool and skipping lease/swap/release when a child has a mismatched pool attached.How to Test
upstream/main(5daa5a0f2f218d2f5c8391dffbc47fe57f76232f): adeepseekparent with azaicredential pool returns the parent pool for adeepseekchild.deepseekchild +zaiparent pool resolves toNoneand does not return the parent pool.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AFor New Skills
N/A
Screenshots / Logs