feat: add model and provider parameters to delegate_task for dynamic model routing - #29899
Closed
joshcheng820222 wants to merge 1 commit into
Closed
Conversation
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.
Collaborator
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! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.providerconfig 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):modelandprovideradded todelegate_task()signatureprovider, its full credential bundle (base_url, api_key, api_mode) is resolved viaresolve_runtime_provider()per-task>top-level>config delegation.*>parent agentExample 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.