Skip to content

feat: add model and provider parameters to delegate_task for dynamic model routing - #29899

Closed
joshcheng820222 wants to merge 1 commit into
NousResearch:mainfrom
joshcheng820222:feat/delegate-task-model-provider
Closed

feat: add model and provider parameters to delegate_task for dynamic model routing#29899
joshcheng820222 wants to merge 1 commit into
NousResearch:mainfrom
joshcheng820222:feat/delegate-task-model-provider

Conversation

@joshcheng820222

Copy link
Copy Markdown

Summary

Enable LLMs to dynamically specify which model/provider a subagent should use when calling delegate_task, making intelligent task-based model routing possible from a Skill layer.

Motivation

Currently, all subagents inherit the parent agent's model. There is no way to route specific tasks to models with different strengths (e.g. coding tasks to a coding model, reasoning tasks to a reasoning model). The delegation.model/delegation.provider config values are static and apply to all subagents.

This is a prerequisite for implementing OpenHuman-style hint routing (e.g. hint:reasoning → MiniMax, hint:coding → Kimi) in a Hermes Skill.

Changes

tools/delegate_tool.py (+80 / -3):

  1. New parameters: model and provider added to delegate_task() signature
  2. JSON schema: Both params exposed to LLM with clear descriptions (top-level + per-task in batch mode)
  3. Credential resolution: When LLM supplies a provider, its full credential bundle (base_url, api_key, api_mode) is resolved via resolve_runtime_provider()
  4. Priority chain: per-task > top-level > config delegation.* > parent agent
  5. Graceful fallback: If LLM-supplied provider fails to resolve, falls back to config credentials with a warning log

Example Usage

After this change, an LLM (or Skill) can call:

{
  "name": "delegate_task",
  "arguments": {
    "goal": "Write a Python function to parse CSV files",
    "provider": "kimi",
    "model": "kimi-for-coding",
    "toolsets": ["terminal", "file"]
  }
}

Or in batch mode with per-task routing:

{
  "name": "delegate_task",
  "arguments": {
    "tasks": [
      {
        "goal": "Analyze the pros and cons of microservices vs monoliths",
        "provider": "minimax-cn",
        "model": "MiniMax-M2.7"
      },
      {
        "goal": "Fix the bug in auth.py line 42",
        "provider": "kimi",
        "model": "kimi-for-coding"
      }
    ]
  }
}

Backwards Compatibility

✅ Fully backwards compatible. Both parameters are optional and default to None, preserving the existing inheritance behavior when not specified.

Allow LLM to dynamically specify which model/provider a subagent should
use when calling delegate_task, enabling intelligent model routing based
on task type (e.g. coding tasks to a coding model, reasoning tasks to
a reasoning model).

Changes:
- Add 'model' and 'provider' optional params to delegate_task() signature
- Add corresponding JSON schema entries for LLM visibility (top-level + per-task)
- Thread params through: schema → handler → task list → _build_child_agent
- LLM-supplied provider resolves credentials via resolve_runtime_provider()
- Priority chain: per-task > top-level > config delegation.* > parent agent
- Graceful fallback: if LLM-supplied provider fails to resolve, falls back
  to config credentials with a warning log

Motivation:
Without this change, all subagents inherit the parent agent's model,
making it impossible to implement intelligent task-based model routing
in a Skill layer. This is a prerequisite for implementing OpenHuman-style
hint routing in Hermes Agent.
@alt-glitch alt-glitch added comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation type/feature New feature or request P3 Low — cosmetic, nice to have labels May 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of open PRs implementing the same feature: #3172, #25813, #7586. Tracking issue: #14974. Multiple prior attempts have been closed (#3734, #25026). Please coordinate with existing open PRs before proceeding.

@joshcheng820222

Copy link
Copy Markdown
Author

Closing this PR — duplicates #12794 which is more comprehensive (model observability plugin, rebased onto dispatch refactor, P2 priority). Happy to see this feature landing! 🙌

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