Skip to content

feat(tools): add per-call delegation provider routing#28940

Open
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:feat/per-call-delegation-routing
Open

feat(tools): add per-call delegation provider routing#28940
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:feat/per-call-delegation-routing

Conversation

@Tranquil-Flow

Copy link
Copy Markdown
Contributor

Summary

Adds per-call and per-task provider / model overrides to delegate_task, so a parent agent can route delegated subagents to different runtime providers/models without changing global config.

This extends the existing delegation credential resolution path rather than introducing a separate provider allowlist. It keeps the existing direct-endpoint behavior for delegation.base_url when no explicit provider override is supplied, while letting an explicit per-call/per-task provider override route through the runtime provider resolver.

Why

Delegation currently supports configuring default delegation credentials, but the tool call itself cannot cleanly say “run this child with provider X/model Y” or mix routing inside one batch. That makes delegation less useful for common agent workflows such as:

  • using a cheaper model/provider for broad research subtasks,
  • using a stronger model/provider for code review or synthesis,
  • mixing routing in a single tasks=[...] fan-out,
  • preserving ACP-based delegation where acp_command is explicitly requested.

What changed

  • Adds top-level provider and model fields to the delegate_task schema and registry dispatch.
  • Adds per-task provider and model fields for batch mode.
  • Resolves each task’s effective credential bundle before constructing child agents, so invalid provider/model routing fails before partial fan-out.
  • Preserves existing delegation.base_url direct-endpoint behavior when no explicit provider override is supplied.
  • Makes explicit per-call/per-task provider overrides bypass delegation.base_url and use the runtime provider resolver.
  • Preserves acp_command precedence: when ACP is explicitly requested, ACP transport wins over provider/model routing.
  • Adds regression coverage for schema, registry dispatch, credential resolution, direct endpoint behavior, mixed routing, and ACP precedence.

Honest comparison with related PRs

This overlaps with existing open attempts to solve the same general feature gap, especially:

This PR is not claiming the feature idea is unique. The potential value of this branch is that it is based on current main, keeps the diff focused to tools/delegate_tool.py and tests/tools/test_delegate.py, and adds a relatively broad regression suite around the behavior boundaries that seemed easiest to regress:

  • top-level and per-task routing,
  • provider + model together,
  • delegation.base_url preservation vs explicit provider override,
  • ACP precedence,
  • registry/schema forwarding,
  • credential/base_url/api_mode threading into child agents.

If maintainers prefer one of the existing PRs, this branch may still be useful as a test/semantics reference rather than a competing implementation.

Related issue

Related to #3719.

I am intentionally using “Related to” rather than “Fixes” because the issue is already closed and there are multiple overlapping open PRs.

How to test

Focused checks run locally:

./.venv/bin/python -m ruff check tools/delegate_tool.py tests/tools/test_delegate.py
./.venv/bin/python -m pytest tests/tools/test_delegate.py -q -o 'addopts=' --tb=short
./.venv/bin/python scripts/check-windows-footguns.py --diff upstream/main...HEAD

Results:

  • Ruff: passed
  • tests/tools/test_delegate.py: 152 passed
  • Windows footgun diff check: passed / no findings

Additional broader checks run before the final commit-message-only amend:

./.venv/bin/python -m pytest tests/hermes_cli/test_runtime_provider_resolution.py tests/hermes_cli/test_api_key_providers.py tests/hermes_cli/test_custom_provider_model_switch.py tests/hermes_cli/test_model_provider_persistence.py tests/run_agent/test_provider_fallback.py -q -o 'addopts=' --tb=short
./.venv/bin/python -m pytest tests/test_model_tools.py tests/test_get_tool_definitions_cache_isolation.py tests/tools/test_delegate_composite_toolsets.py -q -o 'addopts=' --tb=short
./.venv/bin/python -m pytest tests/ --collect-only -q -o 'addopts='

Notes:

  • Full test collection completed successfully with 24,728 tests collected.
  • A broader tests/tools run was killed by the constrained container with exit 137 at partial progress; rerunning pytest’s last-failed set from that aborted run passed. I am not claiming a full-suite pass.

Platforms tested

  • Linux container development environment.

The code path is Python-only and does not add shell commands, OS-specific process management, or new dependencies.

@alt-glitch alt-glitch added type/feature New feature or request comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation P3 Low — cosmetic, nice to have labels May 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #3172 (and #16163, #17756, #25530). Per-call model/provider override for delegate_task has multiple open PRs tracked under #14974.

@Tranquil-Flow Tranquil-Flow force-pushed the feat/per-call-delegation-routing branch from 8bca7e4 to f12cc23 Compare May 25, 2026 11:03
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 P3 Low — cosmetic, nice to have tool/delegate Subagent delegation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants