Skip to content

Bug Report: delegate_task resolves wrong api_mode/base_url for opencode-go when target_model is omitted #18586

@perejaslav

Description

@perejaslav

Summary

When delegation.provider is set to opencode-go, delegate_task spawns subagents with the wrong api_mode and base_url, causing HTTP 404 on every API call.

Root Cause

In tools/delegate_tool.py, _resolve_delegation_credentials() calls:

runtime = resolve_runtime_provider(requested=configured_provider)

without passing target_model=configured_model.

For opencode-go, resolve_runtime_provider() behaves differently depending on whether target_model is provided:

Without target_model With target_model=deepseek-v4-flash
api_mode anthropic_messages chat_completions
base_url https://opencode.ai/zen/go (no /v1) https://opencode.ai/zen/go/v1

The subagent therefore hits an Anthropic-compatible endpoint that does not exist on the OpenCode Go surface, receiving a 404 HTML response.

Steps to Reproduce

  1. Set delegation.provider: opencode-go and delegation.model: deepseek-v4-flash in config.yaml.
  2. Run any delegate_task call.
  3. Subagents fail with HTTP 404 — Not Found | opencode.

Expected Behavior

Subagents should use the same correct endpoint as the main agent (chat_completions on https://opencode.ai/zen/go/v1).

Proposed Fix

Pass target_model to resolve_runtime_provider() in _resolve_delegation_credentials:

runtime = resolve_runtime_provider(requested=configured_provider, target_model=configured_model)

This mirrors the logic used elsewhere (e.g. model_switch.py) and ensures the provider resolves the correct API surface for the chosen model.

Environment

  • Hermes Agent version: 0.11.0 (2026.4.23)
  • Provider: opencode-go
  • Model: deepseek-v4-flash (also affects minimax-m2.7, etc.)

Additional Context

The same bug likely affects opencode-zen because it also uses opencode_model_api_mode() inside resolve_runtime_provider(), which requires target_model to route correctly between codex_responses, anthropic_messages, and chat_completions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/agentCore agent loop, run_agent.py, prompt buildersweeper:implemented-on-mainSweeper: behavior already present on current maintool/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