Skip to content

delegate_task 404 when delegation model differs from main model on opencode-go/opencode-zen #15319

@Emidomenge

Description

@Emidomenge

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/completions404.

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/toolsTool registry, model_tools, toolsetstool/delegateSubagent delegationtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions