Skip to content

fix(tools): prevent credential pool from overriding delegation base_url - #8797

Closed
loktar00 wants to merge 1 commit into
NousResearch:mainfrom
loktar00:fix/delegation-base-url-override
Closed

fix(tools): prevent credential pool from overriding delegation base_url#8797
loktar00 wants to merge 1 commit into
NousResearch:mainfrom
loktar00:fix/delegation-base-url-override

Conversation

@loktar00

@loktar00 loktar00 commented Apr 13, 2026

Copy link
Copy Markdown

What does this PR do?

When both the parent agent and delegation config resolve to provider "custom" (e.g., parent on a local vLLM endpoint, subagents on a different local endpoint), _resolve_child_credential_pool shares the parent's credential pool with the child because the provider matches.

During execution, _run_single_child calls _swap_credential on the leased pool entry, which overwrites child.base_url with the pool's base_url — the parent's endpoint. The delegation base_url was correctly set during AIAgent construction, then silently stomped.

Fixes subagents hitting the parent's endpoint instead of their configured delegation endpoint.

tldr;

Setting my main model endpoint to http://192.168.1.10:8080 to use a model would cause the overriding of the subagent endpoints which were set at http://192.168.1.123:8000. It tried to use the correct model, but what it would do instead was try to hit http://192.168.1.10:8080 looking for the model (which doesn't have it since these are 2 different server instances)

Related Issue

No existing issue found. lol there are A LOT of issues listed but I didn't find anything related.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tools/delegate_tool.py: Added a guard in _build_child_agent() to skip credential pool sharing when the delegation config explicitly provides a different override_base_url from the parent's endpoint. Pool sharing is only meaningful when both agents target the same endpoint for credential rotation.

How to Test

  1. Configure delegation.base_url pointing to endpoint A (e.g., http://192.168.1.123:8080/v1) with a distinct model
  2. Switch the main model to a different local/custom endpoint B (e.g., http://192.168.1.10:8080/v1)
  3. Trigger a delegate_task — the subagent should hit endpoint A, not B
  4. Verify subagent output shows the delegation model (not the parent model)

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/tools/test_delegate.py -q and all 67 tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Debian 12, two separate local vLLM endpoints

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A, no config keys or public API changed
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — change is pure conditional logic, no platform-specific code
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A, no schema changes

Screenshots / Logs

N/A

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation duplicate This issue or pull request already exists labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #11456 — same root cause: credential pool _swap_credential overwrites child base_url when provider matches. See also #13752 and issue #7833.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #11456

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the credential-pool/base-URL interaction. This is an automated hermes-sweeper review; current main already implements the reported guarantee with broader endpoint-aware handling.

  • Commit 48ae8029aae7ffd9f963e549bb0d03b2837e2be0 (fix(delegate): resolve custom-endpoint subagent pools by endpoint identity (#41730)) fixes the same _swap_credential misrouting described here.
  • tools/delegate_tool.py:2927-2971 distinguishes custom runtimes by endpoint-derived pool key, reuses the parent pool only for the same endpoint, and otherwise loads the child endpoint's pool or preserves its fixed credential.
  • tests/tools/test_delegate.py:1750-1813 covers different-endpoint isolation, same-endpoint sharing, and raw unregistered delegation endpoints.
  • This also addresses the root cause noted in the duplicate discussion (delegate_task can overwrite delegated custom endpoint with parent custom credential pool #7833): the child is no longer handed a parent pool merely because both providers are labeled custom.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants