Skip to content

Add model parameter to delegate tool for per-call provider overrides#34681

Open
barryreynolds1 wants to merge 1 commit into
NousResearch:mainfrom
barryreynolds1:feature/delegate-model-parameter
Open

Add model parameter to delegate tool for per-call provider overrides#34681
barryreynolds1 wants to merge 1 commit into
NousResearch:mainfrom
barryreynolds1:feature/delegate-model-parameter

Conversation

@barryreynolds1

Copy link
Copy Markdown

Summary

This PR adds a model parameter to the delegate_task tool, enabling per-call provider:model overrides for delegates. Previously, all delegates were forced to use the provider specified in the delegation config section with no way to override it dynamically.

Problem

The existing delegation system only allowed configuring a single provider for all delegate agents via the delegation config section. This was limiting for scenarios where different subtasks might benefit from different models or providers based on their requirements.

Solution

This change introduces a model parameter that accepts a dictionary with provider and model keys, allowing dynamic routing of delegates to any configured provider at runtime.

Key Changes

  1. Added _resolve_per_call_model() helper function (~line 2203)

    • Takes a {provider, model} dict and resolves full credentials via resolve_runtime_provider()
    • Returns a credential bundle compatible with _resolve_delegation_credentials()
  2. Added model parameter to delegate_task() function (~line 1802)

    • Optional parameter accepting Dict[str, str] with provider/model keys
  3. Added per-call model override logic (~lines 1882-1893)

    • When model is provided, resolves credentials and merges on top of config-based creds
    • Per-call overrides take precedence over delegation config
  4. Added per-task model override support (~lines 1943-1952)

    • Each task in the tasks array can specify its own {provider, model}
    • Task-level overrides take precedence over top-level overrides
  5. Updated DELEGATE_TASK_SCHEMA

    • Added model property at top-level (~lines 2535-2557)
    • Added model property at per-task level (~lines 2479-2493)
  6. Updated registry handler (~line 2581)

    • Now passes model=args.get("model") to the function
  7. Fixed credential references (~lines 1948-1968)

    • Changed creds references to task_creds to support per-task overrides

Example Usage

# Top-level override - all tasks use this provider
delegate_task(
    tasks=[{"goal": "Task 1"}, {"goal": "Task 2"}],
    model={"provider": "anthropic-proxy", "model": "claude-opus-4-8"}
)

# Per-task override - each task uses different provider
delegate_task(
    tasks=[
        {"goal": "Complex reasoning task", "model": {"provider": "anthropic-proxy", "model": "claude-opus-4-8"}},
        {"goal": "Simple extraction task", "model": {"provider": "openai", "model": "gpt-4-turbo"}}
    ]
)

Testing

The changes maintain backward compatibility - existing code without the model parameter continues to work as before, using the delegation config settings.

Impact

This enhancement enables more sophisticated delegation strategies where different subtasks can be dynamically routed to the most appropriate provider/model combination based on task requirements, cost considerations, or performance needs.

This change allows dynamic provider:model selection for delegates at runtime,
removing the previous limitation where all delegates were forced through the
default provider specified in the delegation config.

Key changes:
- Added model parameter to delegate_task() function signature
- Added _resolve_per_call_model() helper to resolve provider credentials
- Added per-call model override logic that merges with config-based creds
- Added per-task model override support in the task loop
- Updated DELEGATE_TASK_SCHEMA to include model property at both top-level
  and per-task level
- Updated registry handler to pass model parameter
- Changed creds references to task_creds to support per-task overrides

This enables more flexible delegation strategies where different subtasks
can be routed to different providers based on their requirements.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have tool/delegate Subagent delegation comp/tools Tool registry, model_tools, toolsets labels May 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This is part of a saturated feature cluster for per-call model/provider overrides on delegate_task. Tracking issue: #14974. Recent tracking issue: #32711. Multiple open competing PRs implement the same feature: #12794, #19719, #25530, #17756, among others. See also recent duplicate issues #34489, #23467.

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

Labels

comp/tools Tool registry, model_tools, toolsets 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