Skip to content

Feature: Per-call model/provider override on delegate_task #3719

@HenkDz

Description

@HenkDz

Summary

Allow the parent agent to specify model, provider, and optionally base_url on each delegate_task call (and per-task in batch mode), so it can dynamically route subagents to different models based on task type.

Motivation

Currently, subagent model selection is static via delegation.model / delegation.provider in config.yaml. This means ALL subagents use the same model. In practice, different tasks benefit from different models:

  • Code tasks → fast, code-tuned model (e.g. glm-5.1)
  • Research/reasoning → slower but stronger reasoning model (e.g. glm-5)
  • Main thread → default configured model (e.g. glm-5-turbo)

The cronjob tool already supports per-job model/provider/base_url overrides — delegate_task should too. The plumbing already exists in _resolve_delegation_credentials() and _build_child_agent() (which already accepts override_provider/override_base_url/override_api_key/override_api_mode). This is mostly wiring the tool schema → handler path.

Proposed API

Single task mode

{
  "name": "delegate_task",
  "arguments": {
    "goal": "Implement the auth middleware",
    "context": "...",
    "model": "glm-5.1",
    "provider": "zai"
  }
}

Batch mode (per-task overrides)

{
  "name": "delegate_task",
  "arguments": {
    "tasks": [
      {
        "goal": "Research competitors",
        "model": "glm-5",
        "provider": "zai"
      },
      {
        "goal": "Write integration tests",
        "model": "glm-5.1"
      }
    ]
  }
}

Fallback chain

per-call model/providerconfig delegation.model/providerinherit from parent

This preserves backward compatibility — if no per-call override is given, behavior is identical to today.

Implementation notes

  • _build_child_agent() already accepts model and override_provider — just needs to be wired from the tool arguments
  • Need _resolve_delegation_credentials() or a new helper to resolve a one-off provider string (reusing resolve_runtime_provider()) when passed per-call
  • Schema changes to DELEGATE_TASK_SCHEMA: add model (string) and provider (string) at top level, plus model/provider inside each batch task item
  • Provider validation: resolve at delegation time, return clear error if provider has no API key
  • Consider adding base_url as well for direct endpoint overrides (already supported in config)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions