Skip to content

feat(tools): add per-task routing to delegate_task#31537

Open
jmelchiori wants to merge 1 commit into
NousResearch:mainfrom
jmelchiori:feat/delegate-per-task-routing
Open

feat(tools): add per-task routing to delegate_task#31537
jmelchiori wants to merge 1 commit into
NousResearch:mainfrom
jmelchiori:feat/delegate-per-task-routing

Conversation

@jmelchiori

Copy link
Copy Markdown

Summary

  • Add per-task model, provider, and reasoning_effort routing fields to delegate_task batch items.
  • Preserve backwards compatibility for existing single-task and batch callers, including keeping top-level batch routing fields from becoming implicit per-item defaults.
  • Forward routing fields through run_agent dispatch and clean up partially built child agents when build-stage failures occur.

Test plan

  • scripts/run_tests.sh tests/tools/test_delegate.py tests/agent/test_subagent_stop_hook.py tests/run_agent/test_interrupt_propagation.py tests/run_agent/test_real_interrupt_subagent.py — 164 passed.
  • scripts/run_tests.sh tests/acp/test_auth.py — 10 passed after bootstrapping the wrapper-supported [all,dev] venv.
  • scripts/run_tests.sh tests/run_agent/test_streaming.py tests/run_agent/test_stream_drop_logging.py tests/run_agent/test_session_id_env.py tests/tools/test_discord_tool.py — 143 passed after installing browser assets in the same hermetic HOME used by scripts/run_tests.sh.
  • scripts/run_tests.sh full suite was attempted locally. It still fails outside this change area in this container/profile environment, including Docker install-method detection, missing systemctl/user-systemd assumptions, and tests that monkeypatch HERMES_HOME to temp dirs and then hit browser lazy-install timeouts. The changed/adjacent delegate tests above are green; CI should be the source of truth for the full matrix.

Add optional model, provider, and reasoning_effort fields to delegate_task for single-task and per-task batch routing. Resolve credentials per task only when routing overrides are present, preserve default credential caching, and apply reasoning precedence as task > config > parent.

Also clean up partially built child agents if later task credential resolution fails before execution.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder tool/delegate Subagent delegation labels May 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with saturated per-task routing cluster: #20000, #26736, #23266, #17756, #17718, #6771, and others. Tracking issue #14974. Recommend coordinating with the existing open PRs before proceeding.

@jmelchiori

Copy link
Copy Markdown
Author

Thanks, agreed this area is saturated.

I did a pass over the linked cluster plus the nearby PRs I could find. The tracking issue (#14974) has been open since Apr 24, and I count at least ten related open PRs/proposals in or near this space (#6771, #7201, #12794, #17718, #17756, #20000, #23266, #23649, #25530, #26736). Some of those date back to Apr 9, so this has effectively been sitting for a month+ with multiple candidate implementations and no obvious convergence. I don't want this PR to add to that churn.

What this branch is trying to contribute as a possible consolidation candidate:

  • includes the current run_agent.py / _dispatch_delegate_task() forwarding path, which some prior branches appear to miss;
  • avoids exposing api_key as a delegate_task schema field;
  • reuses _resolve_delegation_credentials() for provider overrides, including clearing stale base_url when a task switches provider;
  • adds per-task reasoning_effort routing;
  • has regression coverage for schema exposure, single-task routing, batch per-task routing, run-agent forwarding, credential errors, and build-stage child cleanup;
  • includes cleanup hardening so partially built children are not leaked on build-stage failures.

One intentional semantic choice here: in batch mode, top-level model / provider / reasoning_effort are not treated as defaults for every task. Batch routing is explicit per tasks[] item to avoid accidentally routing an entire batch. If maintainers prefer the more common per-task > top-level > config > parent precedence from other candidates, I can adjust this branch.

Happy to coordinate whichever direction maintainers prefer: keep this as a small consolidation candidate, port the tests/cleanup pieces into a chosen canonical PR, or close this if another implementation is selected.

agt-user pushed a commit to agt-user/hermes-agent that referenced this pull request Jun 9, 2026
Allow individual tasks in the  array to specify their own
 and/or , overriding the global delegation config
for that task only.

When a per-task override is present,
is called with a task-scoped config so that base_url, api_key, and
api_mode are derived correctly from the per-task provider — not the
global delegation config. Tasks without overrides fall back to the
pre-resolved  dict as before (no regression for existing usage).

Changes:
- : add  and  fields to the
  per-task object inside  array
-  loop: resolve per-task credentials when override
  is present; otherwise reuse global  (zero overhead)

Closes NousResearch#35437
Related: NousResearch#34489, NousResearch#31537, NousResearch#36790, NousResearch#30388, NousResearch#37966
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder 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