Skip to content

feat: add model/provider/base_url/api_format parameters to delegate_task (consolidating #5012, #10995, #17685, #23467, #32711) #35437

@JerryLiu369

Description

@JerryLiu369

Problem

delegate_task() has no way to specify which model/provider a subagent should use — neither at the top level (single task mode) nor per-task (batch mode). Subagents always inherit the parent agent model or fall back to delegation config, making it impossible to:

  • Route cheap mechanical subtasks to a fast/cheap model
  • Use a vision-capable model for a specific subagent
  • Point a subagent at a completely different provider/endpoint

Five open issues track this gap from various angles: #5012, #10995, #17685, #23467, #32711.

Desired API

Add optional parameters to both the top-level delegate_task() and individual tasks[] items.

Top-level (applies to all subagents unless overridden per-task)

  • provider (str, optional) — provider name (e.g. "openrouter", "anthropic", or "custom:")
  • model (str, optional) — model name (e.g. "qwen/qwen-turbo", "claude-sonnet-4")
  • base_url (str, optional) — override the API endpoint base URL
  • api_format (str, optional) — "openai" | "anthropic" | "codex" etc. (maps to internal api_mode)
  • api_key (str, optional) — API key for the target provider

Per-task (overrides top-level for that specific child)

Each item in tasks[] should also accept the same fields: provider, model, base_url, api_format, api_key.

Why this is feasible

The internal _build_child_agent() (line 870 in tools/delegate_tool.py) already supports override_provider, override_base_url, override_api_key, override_api_mode — but these are only populated from delegation config in config.yaml. The gap is purely in the tool schema and the handler wiring: the parameters exist in the builder, they just aren't exposed to the model via delegate_task().

Implementation sketch

  1. Add provider/model/base_url/api_format/api_key to DELEGATE_TASK_SCHEMA (both top-level properties and tasks.items.properties)
  2. Add corresponding parameters to delegate_task() function signature
  3. Thread them through the handler into _build_child_agent() override params
  4. For api_format, map to the internal api_mode string (the builder already takes override_api_mode)

Related issues (all should be closed by this unified implementation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/toolsTool registry, model_tools, toolsetsduplicateThis issue or pull request already existstool/delegateSubagent delegationtype/featureNew feature or request

    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