fix(delegation): pass target_model to resolve_runtime_provider in _resolve_delegation_credentials#15320
Conversation
…solve_delegation_credentials
When delegation.model differs from model.default and the provider is
opencode-go or opencode-zen, the wrong api_mode is computed because
resolve_runtime_provider falls back to model_cfg.get('default') — the
main model — instead of the configured delegation model.
For example, with model.default=minimax-m2.7 (anthropic_messages) and
delegation.model=glm-5.1 (chat_completions), subagents get
anthropic_messages, which strips /v1 from the base URL and causes a 404.
resolve_runtime_provider already accepts target_model for exactly this
purpose; _resolve_delegation_credentials just wasn't passing it.
Fixes NousResearch#15319
Related: NousResearch#13678
Code Review: fix(delegation): pass target_model to resolve_runtime_providerVerdict: Approve with nitsThis is a correct, minimal fix for a real bug. The change is one argument addition that wires an already-available parameter through to where it's needed. The fix is obviously safe — Correctness AnalysisThe bug is real and well-diagnosed. The fix is correct.
Call path verified:
All three paths fall back to Edge case: Issues Found
NitThe PR description focuses on Scope Check
RecommendationApprove after:
The fix itself is correct and minimal. The missing test updates should be straightforward. |
|
If this has already been fixed in latest version. This can be closed |
|
Salvaged via #19623 onto current main - your commit authorship was preserved. Thanks! |
…on (NousResearch#15319) When delegation.model differs from the parent model (e.g., delegating to claude-opus-4-6 on an opencode-zen provider while the parent uses a chat_completions model), resolve_runtime_provider needs the target model to select the correct api_mode. Without it, the delegate inherits the parent's api_mode and gets 404 errors. Supersedes NousResearch#15320.
Problem
When
delegation.modeldiffers frommodel.defaultonopencode-gooropencode-zen,delegate_taskfails with a 404._resolve_delegation_credentialscallsresolve_runtime_provider(requested=configured_provider)without atarget_model, soapi_modeis computed frommodel_cfg.get("default")— the main model — instead of the delegation model.Example:
model.default=minimax-m2.7(→anthropic_messages) +delegation.model=glm-5.1(→chat_completions). The subagent inheritsanthropic_messages,/v1is stripped from the base URL, and the request hitshttps://opencode.ai/zen/go/messagesinstead ofhttps://opencode.ai/zen/go/v1/chat/completions→ 404.Fix
resolve_runtime_provideralready acceptstarget_modelfor this exact purpose (see its docstring: "Callers performing an explicit mid-session model switch should pass the new model here"). The delegation path just wasn't passing it.Testing
Verified locally with
opencode-go,model.default=minimax-m2.7,delegation.model=glm-5.1:api_mode=anthropic_messages,base_url=https://opencode.ai/zen/go→ 404api_mode=chat_completions,base_url=https://opencode.ai/zen/go/v1→ successCloses #15319
Related: #13678