feat(delegation): per-task model/provider overrides in batch dispatch#20779
Closed
chrisworksai wants to merge 1 commit into
Closed
feat(delegation): per-task model/provider overrides in batch dispatch#20779chrisworksai wants to merge 1 commit into
chrisworksai wants to merge 1 commit into
Conversation
Lets each task in a batch target a different model/provider:
delegate_task(tasks=[
{"goal": "...", "provider": "anthropic", "model": "claude-opus-4-7"},
{"goal": "...", "provider": "openai", "model": "gpt-5"},
{"goal": "...", "provider": "openrouter", "model": "..."}
])
Useful for cross-provider parallel work — A/B comparison,
adversarial review across diverse models, evaluation harnesses
that need each task on a controlled provider.
Implementation
--------------
* `_resolve_task_credentials(task, delegation_creds)` resolves the
per-task creds, falling back to the batch creds when neither
field is set on the task.
* The per-task loop in `delegate_task` calls it once per task and
passes the resolved creds to `_build_child_agent` via the
existing `override_*` kwargs — no new plumbing in the child
builder.
* Per-task schema gains `model` and `provider` fields.
Failure mode: if a task's `provider` doesn't resolve (typo, missing
runtime config), we log a warning and run that task on the batch
default rather than failing every other task in the batch.
Compatibility: tasks without `model`/`provider` behave exactly as
today — `_resolve_task_credentials` short-circuits when neither is
set and returns the batch creds unchanged.
Collaborator
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets each task in a
delegate_taskbatch target a different model/provider:All three children spawn in parallel under the existing concurrency cap, each on its specified provider. Tasks without
model/provideruse the batch default (existing behaviour preserved).Why
The current contract supports a single
delegation.providerfor the whole batch — every child runs on the same provider:model pair. That's the right default for fan-out research where the model choice is uniform, but it blocks several patterns where the value comes from diversity:Today users have to either:
delegate_taskcalls (loses parallelism), orImplementation
Three changes, all in
tools/delegate_tool.py:1.
_resolve_task_credentials(task, delegation_creds) -> dictNew helper that resolves per-task creds. Returns the same shape as
_resolve_delegation_credentialsso the result drops into the existing_build_child_agentoverride_*kwargs without new plumbing.Resolution priority:
task.provider/model>delegation_creds.Failure handling: if a task's
providerdoesn't resolve (typo, missing runtime config), log a warning and returndelegation_credsunchanged. Why: failing the whole batch over one bad entry is worse UX than running that task on the default provider — the user can see the warning, fix the config, and the rest of the batch already produced useful output.2. Per-task loop in
delegate_taskOne additional line per task before the
_build_child_agentcall:Then
_build_child_agentreceivestask_creds["..."]instead ofcreds["..."]. No structural changes to the loop.3. Schema additions
Per-task entries can now declare
modelandproviderfields. Top-leveltasks[].properties.modelandtasks[].properties.providerwere missing — adding them lets the model legitimately request the override.Compatibility
model/providerare unaffected:_resolve_task_credentialsshort-circuits and returns the batch creds.delegate_task(goal=...)) is unchanged — only the per-task loop is touched._resolve_delegation_credentialsis unchanged;_resolve_task_credentialsreuses the sameresolve_runtime_providermachinery.Test plan
delegation.providerprovider="anthropic": that task runs on Anthropic, others on default🤖 Generated with Claude Code