Bug
When delegation.model differs from model.default and the provider is opencode-go or opencode-zen, delegate_task fails with a 404 because the delegation subagent hits the wrong API endpoint.
Root cause
_resolve_delegation_credentials in tools/delegate_tool.py calls:
runtime = resolve_runtime_provider(requested=configured_provider)
resolve_runtime_provider then computes api_mode using model_cfg.get("default") — the main model, not the delegation model. When the main model is a MiniMax model (minimax-m2.7), this returns anthropic_messages, which causes the trailing /v1 to be stripped from the base URL. The subagent then calls https://opencode.ai/zen/go/messages instead of https://opencode.ai/zen/go/v1/chat/completions → 404.
resolve_runtime_provider already accepts a target_model parameter for exactly this purpose (see its docstring). It just isn't being passed.
Fix
# tools/delegate_tool.py, _resolve_delegation_credentials()
# Before:
runtime = resolve_runtime_provider(requested=configured_provider)
# After:
runtime = resolve_runtime_provider(requested=configured_provider, target_model=configured_model)
PR: #15320
Reproduction config
model:
provider: opencode-go
default: minimax-m2.7 # uses anthropic_messages
delegation:
provider: opencode-go
model: glm-5.1 # should use chat_completions — but doesn't
With this config, delegate_task calls resolve with minimax-m2.7 as the effective model, gets anthropic_messages + stripped base URL, and 404s.
Expected
resolve_runtime_provider is called with target_model="glm-5.1", returns chat_completions + https://opencode.ai/zen/go/v1, and the delegation request succeeds.
Related
#13678 — similar symptom (404 on opencode-go delegation) from a different root cause (env var not loaded in child process)
Bug
When
delegation.modeldiffers frommodel.defaultand the provider isopencode-gooropencode-zen,delegate_taskfails with a 404 because the delegation subagent hits the wrong API endpoint.Root cause
_resolve_delegation_credentialsintools/delegate_tool.pycalls:resolve_runtime_providerthen computesapi_modeusingmodel_cfg.get("default")— the main model, not the delegation model. When the main model is a MiniMax model (minimax-m2.7), this returnsanthropic_messages, which causes the trailing/v1to be stripped from the base URL. The subagent then callshttps://opencode.ai/zen/go/messagesinstead ofhttps://opencode.ai/zen/go/v1/chat/completions→ 404.resolve_runtime_provideralready accepts atarget_modelparameter for exactly this purpose (see its docstring). It just isn't being passed.Fix
PR: #15320
Reproduction config
With this config,
delegate_taskcalls resolve withminimax-m2.7as the effective model, getsanthropic_messages+ stripped base URL, and 404s.Expected
resolve_runtime_provideris called withtarget_model="glm-5.1", returnschat_completions+https://opencode.ai/zen/go/v1, and the delegation request succeeds.Related
#13678 — similar symptom (404 on opencode-go delegation) from a different root cause (env var not loaded in child process)