Skip to content

fix(delegate): guard child credential pool binding - #35499

Closed
JabberELF wants to merge 1 commit into
NousResearch:mainfrom
JabberELF:fix/delegate-credential-pool-runtime-guard
Closed

fix(delegate): guard child credential pool binding#35499
JabberELF wants to merge 1 commit into
NousResearch:mainfrom
JabberELF:fix/delegate-credential-pool-runtime-guard

Conversation

@JabberELF

@JabberELF JabberELF commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR hardens delegate_task credential-pool handling so a child agent does not bind a leased credential from a different provider/runtime endpoint.

It adds two guards:

  • _run_single_child() now verifies the leased credential matches the child runtime before calling _swap_credential().
    • Provider identity must match.
    • If both sides expose a concrete base URL, the normalized base URLs must match.
  • _resolve_child_credential_pool() no longer blindly shares the parent's pool when the parent pool carries explicit provider metadata that differs from the child provider. It falls back to loading the child provider's own pool instead.

This preserves the existing compatibility behavior for old/test pool objects that lack provider metadata, and keeps custom:<name> compatible with the bare configured custom-provider name.

Why

The existing delegation path can accidentally combine a child runtime from one provider with a leased credential/base URL from another provider. One observed shape is an openai-codex child using the Codex model/runtime while swapping to a Xiaomi OpenAI-compatible endpoint from the credential pool, producing HTTP 404s.

Related but different prior work:

This PR focuses specifically on the credential-pool lease/swap contamination path.

Tests

python -m py_compile tools/delegate_tool.py tests/tools/test_delegate.py
python -m pytest -o addopts='' tests/tools/test_delegate.py::TestChildCredentialPoolResolution tests/tools/test_delegate.py::TestChildCredentialLeasing -q
python -m pytest -o addopts='' tests/tools/test_delegate.py -q
git diff --check -- tools/delegate_tool.py tests/tools/test_delegate.py

Results:

  • py_compile: passed
  • targeted credential-pool/delegation tests: 12 passed
  • full tests/tools/test_delegate.py: 137 passed
  • git diff --check: passed

The only warning seen locally is the pre-existing discord.player / audioop Python 3.13 deprecation warning.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/delegate Subagent delegation area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists labels May 30, 2026
@JabberELF

Copy link
Copy Markdown
Contributor Author

Closing — upstream main already implements this via in (line 2371). Child credential pool binding is guarded with at both assignment (line 1187) and lease acquisition (line 1395). This PR is now redundant.

@JabberELF JabberELF closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants