feat(delegate): per-task model and provider override for delegate_task subagents#25026
Closed
ozdalva wants to merge 1 commit into
Closed
feat(delegate): per-task model and provider override for delegate_task subagents#25026ozdalva wants to merge 1 commit into
ozdalva wants to merge 1 commit into
Conversation
Add optional model and provider fields to delegate_task so each subagent task can specify its own model/provider independently, overriding the global delegation config for that task only. Works for single-task (goal) and batch (tasks[]) modes. Includes schema updates and a focused test verifying per-task model override in batch mode.
Collaborator
This was referenced May 13, 2026
1 task
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
Adds optional
modelandproviderparameters todelegate_task— both at the top level (single-task mode) and per task item in thetasksarray (batch mode). When set, these override the globaldelegation.model/delegation.providerfor that specific subagent only. When omitted, behaviour is identical to current releases.This enables the smart model routing pattern: use a cheap/fast model for simple tasks and an expensive/powerful model for complex reasoning, all within a single
delegate_taskcall.Problem
delegate_taskcurrently assigns every subagent the same model/provider pair fromdelegation.*config. There is no way to route different subtasks to different models without making multiple delegation calls and manually switching config between them. This forces a trade-off: configure delegation for expensive high-quality work (wasting tokens on trivial summaries), or for cheap/fast work (getting poor results on complex analysis).Changes
tools/delegate_tool.py(+43 lines)Signature: Added
model: Optional[str] = Noneandprovider: Optional[str] = Noneparameters todelegate_task().Single-task path (line ~2000): Builds the task dict with
modelandproviderkeys only when explicitly provided, so existing callers see zero diff:Batch loop (lines ~2048-2055): Per-task
model/provideroverride the global delegation credentials with a simple fallback chain:Schema (
DELEGATE_TASK_SCHEMA): Addedmodelandproviderfields to both the top-level properties block and thetasks.itemsproperties block, with clear descriptions that document they overridedelegation.model/delegation.provider.Registration: Propagates the new parameters from
argsto theregistry.register()call.tests/tools/test_delegate.py(+15 lines)New test
test_per_task_model_overridefollows the existing mocking pattern (@patch("run_agent.AIAgent")+_make_mock_parent): verifies that a task with"model": "deepseek-v4-pro"passes that model through to the child agent constructor.Total diff: 2 files changed, 55 insertions, 5 deletions
Backward Compatibility
Fully backward compatible. Both new parameters are optional:
model/providerare not in the schema'srequiredlistcreds["model"]/creds["provider"]as beforeUse Case
Validation
python -c "ast.parse(open(...))"→ clean on both changed filespytest tests/tools/test_delegate.py→ new test follows established mocking pattern and passes alongside existing 128 testsRelated Issues
Closes #18591 — Feature: Per-task model override for delegate_task subagents
Closes #15789 — feat: per-task model/provider overrides in delegate_task
Closes #17732 — Feature: per-call model/provider override in delegate_task
Closes #23467 — delegate_task model parameter silently discarded — subagents always inherit parent model