Skip to content

feat(delegate): per-task model and provider overrides#23266

Open
alex-abell wants to merge 1 commit into
NousResearch:mainfrom
alex-abell:feat/per-task-model-override
Open

feat(delegate): per-task model and provider overrides#23266
alex-abell wants to merge 1 commit into
NousResearch:mainfrom
alex-abell:feat/per-task-model-override

Conversation

@alex-abell

Copy link
Copy Markdown

Problem

delegate_task applies a single global model to every child agent (from delegation.model in config.yaml). There's no way to route individual subtasks to different models without changing the global config between runs.

Cron jobs already support per-job model + provider overrides. This PR brings delegate_task to parity.

Solution

Add optional model and provider fields to each task object in the tasks batch array. When present, that task's child agent is built with a task-specific credential bundle. When absent, the task inherits global delegation creds — no behavior change for existing callers.

delegate_task(tasks=[
    {"goal": "quick summary"},  # uses default model
    {"goal": "deep reasoning task", "model": "anthropic/claude-opus-4", "provider": "openrouter"},
])

Changes

  • tools/delegate_tool.py: resolve per-task creds when task.model or task.provider is set; pass task_creds into _build_child_agent for that task
  • tools/delegate_tool.py: add model and provider to DELEGATE_TASK_SCHEMA tasks[].items.properties
  • tools/delegate_tool.py: add MODEL ROUTING section to tool description
  • tests/tools/test_delegate.py: 4 new tests in TestPerTaskModelOverride

Test plan

python -m pytest tests/tools/test_delegate.py -o 'addopts=' -q

124 pass (same as before + 4 new). The 4 pre-existing failures in TestDelegationCredentialResolution and TestDelegateHeartbeat are unrelated to this change and reproduce on main.

Allow each task in the 'tasks' batch array to specify its own model
and provider, routing individual subtasks to different LLMs while the
rest inherit the global delegation config.

Problem: delegate_task applied a single global model (from
delegation.model in config.yaml) to every child. There was no way to
say 'run this hard reasoning task on Opus, everything else on Sonnet'
without changing the global config.

Solution: add optional model and provider fields to each task object
in the tasks array. When present, _build_child_agent is called with
a task-specific credential bundle resolved from a config overlay
(global config + per-task overrides). When absent, the task falls back
to the existing global creds — no behavior change for existing callers.

Changes:
- tools/delegate_tool.py: resolve per-task creds when task.model or
  task.provider is set; pass task_creds into _build_child_agent
  instead of the global creds for that task
- tools/delegate_tool.py: add model and provider to DELEGATE_TASK_SCHEMA
  tasks[].items.properties with descriptive docstrings
- tools/delegate_tool.py: add MODEL ROUTING section to tool description
- tests/tools/test_delegate.py: TestPerTaskModelOverride (4 tests)

Note: cron jobs already support per-job model/provider (cronjob_tools.py).
This brings delegate_task to parity. Both use OpenRouter's model routing
under the hood — provider='openrouter' + any model string works today.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have tool/delegate Subagent delegation duplicate This issue or pull request already exists labels May 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #17756 — per-task model/provider overrides in delegate_task. Saturated feature cluster with 5+ open PRs (#17756, #17718, #3172, #12794, #16163).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists 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