Skip to content

Fix delegate_task model/provider precedence and expose per-task overrides#17581

Open
afurm wants to merge 1 commit into
NousResearch:mainfrom
afurm:af/delegate-model-provider-overrides
Open

Fix delegate_task model/provider precedence and expose per-task overrides#17581
afurm wants to merge 1 commit into
NousResearch:mainfrom
afurm:af/delegate-model-provider-overrides

Conversation

@afurm

@afurm afurm commented Apr 29, 2026

Copy link
Copy Markdown

What does this PR do?

Fix delegation so delegate_task consistently applies model/provider override precedence across top-level and per-task configuration, and forwards the resolved credentials to child agents. This resolves cases where users pass model/provider but child tasks still use unintended defaults.

Also updates the tool schema and tests to document and verify the new behavior.

Related Issue

Fixes #10995

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added optional top-level model and provider args to delegate_task in tools/delegate_tool.py.
  • Applied precedence handling so delegation credentials resolve in this order:
    • task-level model/provider
    • top-level model/provider
    • delegation.model/delegation.provider from config
    • parent agent fallback
  • Passed resolved per-task credentials into child construction (model, override_provider, override_base_url, override_api_key, override_api_mode) in tools/delegate_tool.py.
  • Extended DELEGATE_TASK_SCHEMA with:
    • top-level model, provider
    • per-task tasks[].model, tasks[].provider
    • precedence descriptions for both levels.
  • Added regression/integration coverage in tests/tools/test_delegate.py:
    • TestDelegateRequirements.test_schema_valid now checks new schema fields.
    • test_top_level_model_provider_overrides validates top-level propagation.
    • test_per_task_model_provider_override validates per-task precedence over top-level values.

How to Test

  1. Run focused tests:
    • scripts/run_tests.sh tests/tools/test_delegate.py
  2. Run the targeted new tests:
    • scripts/run_tests.sh -k "model_provider_override"
  3. Optional: execute a delegation call manually with mixed config and task-level values and verify child creation uses task-level values where provided, then top-level values, then config fallback.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior

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

Labels

P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: delegate_task should support per-task model selection

2 participants