feat(delegate): add per-call model/provider/base_url overrides - #17756
feat(delegate): add per-call model/provider/base_url overrides#17756mddragon18 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds per-invocation runtime overrides to delegate_task so callers can choose a different model/provider (and related connection settings) for spawned subagents, including per-task overrides in batch mode.
Changes:
- Extended
delegate_task()to acceptmodel,provider,base_url, andapi_key, with per-task override precedence in batch delegation. - Updated
DELEGATE_TASK_SCHEMAto expose the new override fields at both top-level and per-task item level. - Added/updated tests covering schema fields, per-call overrides, and subagent cost rollup behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tools/delegate_tool.py | Adds per-call/per-task runtime override parameters + schema exposure; includes subagent cost rollup and ACP transport handling updates. |
| tests/tools/test_delegate.py | Updates schema validation assertions and adds coverage for per-call overrides and cost rollup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Per-child credential resolution: merge per-task overrides on top of effective_cfg | ||
| task_cfg = dict(effective_cfg) | ||
| if "model" in t: | ||
| task_cfg["model"] = t.get("model") | ||
| if "provider" in t: | ||
| task_cfg["provider"] = t.get("provider") | ||
| if "base_url" in t: | ||
| task_cfg["base_url"] = t.get("base_url") | ||
| if "api_key" in t: | ||
| task_cfg["api_key"] = t.get("api_key") |
| "api_key": { | ||
| "type": "string", | ||
| "description": "Override API key for the child agent(s).", | ||
| }, |
There was a problem hiding this comment.
check the updated PR again for this
Add model, provider, and base_url parameters to delegate_task for both single-task and batch modes. api_key is kept in the code path (works via delegation.api_key config) but excluded from the schema for security. Fixes: model=None no longer clears the configured delegation model; per-child loop uses .get() is not None checks instead of 'in' checks.
|
Rebased onto latest Changes since initial review:
|
|
The patch in delegate_tool.py is correct, but it also needs forwarding in Without this, the parameters arrive in The fix is adding: model=function_args.get("model"),
provider=function_args.get("provider"),
base_url=function_args.get("base_url"),
api_key=function_args.get("api_key"),before |
|
We do not want this |
Summary
Add
model,provider, andbase_urlparameters todelegate_task, allowing per-call overrides for subagents — both at the top level and per-task in batch mode.api_keyis kept in the code path (works viadelegation.api_keyconfig) but excluded from the schema for security.Changes
tools/delegate_tool.py:delegate_task()function signature withmodel,provider,base_urlparamsDELEGATE_TASK_SCHEMAat top-level and per-task —api_keyexcluded from schema to prevent LLM secret leakagetests/tools/test_delegate.py:test_schema_validto assert new fieldstest_per_call_model_overrideSecurity
api_keyis NOT exposed to the model via the schema. The code path still supports it internally — set viadelegation.api_keyin config.yaml — but the LLM cannot inject or read it through tool calls.Example
Verification