Skip to content

fix(delegate): honor runtime default model during provider resolution#17587

Merged
teknium1 merged 1 commit into
NousResearch:mainfrom
johnncenae:fix/delegate-tool-provider-model-fallback
May 1, 2026
Merged

fix(delegate): honor runtime default model during provider resolution#17587
teknium1 merged 1 commit into
NousResearch:mainfrom
johnncenae:fix/delegate-tool-provider-model-fallback

Conversation

@johnncenae

Copy link
Copy Markdown
Contributor

Summary

This fixes a bug in delegate_task where a delegated provider override could lose the runtime resolver's default model.

When delegation.provider was set but delegation.model was 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() when delegation.provider is configured. That resolver may return a runtime-specific model, especially for named custom providers or provider-specific defaults.

Before this change, _resolve_delegation_credentials() discarded runtime["model"] and only returned the explicitly configured delegation.model value. In practice that meant:

  • delegation.provider is set
  • delegation.model is empty
  • resolve_runtime_provider() returns a default model
  • the child agent still inherits the parent model instead of using the resolved model

This 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:

  • if delegation.model is explicitly set, keep using it
  • otherwise, if resolve_runtime_provider() returns runtime["model"], use that
  • otherwise, preserve the existing inheritance behavior

This 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_missing

The test covers this case:

  • delegation.provider = "custom:my-server"
  • delegation.model = ""
  • resolve_runtime_provider() returns model = "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

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/delegate Subagent delegation labels Apr 29, 2026
@teknium1 teknium1 merged commit 9ae1fa9 into NousResearch:main May 1, 2026
6 of 7 checks passed
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.

3 participants