fix(delegate): honor runtime default model during provider resolution#17587
Merged
teknium1 merged 1 commit intoMay 1, 2026
Merged
Conversation
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
This fixes a bug in
delegate_taskwhere a delegated provider override could lose the runtime resolver's default model.When
delegation.providerwas set butdelegation.modelwas left empty, the child agent did not use the provider's resolved default model. Instead, it fell back to the parent model, which could send the wrong model slug to the delegated endpoint.Problem
The delegation credential path already calls
resolve_runtime_provider()whendelegation.provideris configured. That resolver may return a runtime-specific model, especially for named custom providers or provider-specific defaults.Before this change,
_resolve_delegation_credentials()discardedruntime["model"]and only returned the explicitly configureddelegation.modelvalue. In practice that meant:delegation.provideris setdelegation.modelis emptyresolve_runtime_provider()returns a default modelThis can cause delegated runs to target the right provider/base_url but the wrong model.
Fix
Use the resolved runtime model as the fallback model for delegated provider overrides.
Behavior is now:
delegation.modelis explicitly set, keep using itresolve_runtime_provider()returnsruntime["model"], use thatThis keeps the change narrow and only affects the provider-override path.
Tests
Added a regression test:
tests/tools/test_delegate.py::TestDelegationCredentialResolution::test_provider_resolution_uses_runtime_model_when_config_model_missingThe test covers this case:
delegation.provider = "custom:my-server"delegation.model = ""resolve_runtime_provider()returnsmodel = "server-default-model"Expected result:
the delegated child uses
"server-default-model"Validation
The new targeted regression test passed with:
uv run pytest tests/tools/test_delegate.py::TestDelegationCredentialResolution::test_provider_resolution_uses_runtime_model_when_config_model_missing