fix(delegate): resolve Portal model aliases before delegating to upstream API#28644
Open
JasonOA888 wants to merge 1 commit into
Open
fix(delegate): resolve Portal model aliases before delegating to upstream API#28644JasonOA888 wants to merge 1 commit into
JasonOA888 wants to merge 1 commit into
Conversation
…ream API Portal free-tier recommendations (e.g. nemotron-free, llama70b-free) and short aliases (e.g. sonnet, opus) are convenient for display but are NOT valid model IDs for upstream API calls. When such an alias lands in delegation.model (or is resolved from a runtime provider default), the delegation call fails with a 400 from the upstream API. This adds _resolve_model_alias() which: 1. Passes through fully-qualified model IDs (containing /) unchanged 2. Tries detect_static_provider_for_model() to resolve known aliases 3. Strips -free/_free suffixes and retries resolution 4. Falls back to the original string with a warning log Applied at all three return points in _resolve_delegation_credentials(): - base_url path - no-provider path (inherit from parent) - provider-resolved path Closes NousResearch#28023
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
Fixes #28023
Portal free-tier recommendations (e.g.
nemotron-free,llama70b-free) and short aliases (e.g.sonnet,opus) are convenient for display but are NOT valid model IDs for upstream API calls. When such an alias lands indelegation.model(or is resolved from a runtime provider default), the delegation call fails with a 400 Bad Request from the upstream API.Root Cause
_resolve_delegation_credentials()passes the configured model string through verbatim to the child agent. When the model is a Portal alias likenemotron-free, OpenRouter rejects it with:Changes
Added
_resolve_model_alias()intools/delegate_tool.pywhich:/) — no resolution neededdetect_static_provider_for_model()— reuses the same alias logic as/modelswitching-free/_freesuffixes and retries (handles Portal aliases likenemotron-free→nemotron→nvidia/nemotron-3-super-120b-a12b)Applied at all three return points in
_resolve_delegation_credentials():delegation.base_urlpathresolve_runtime_provider)Testing
ast.parse()passesdetect_static_provider_for_model()which has its own test coverageFiles Changed
tools/delegate_tool.py— +71 lines (_resolve_model_alias+ 3 call sites)