Skip to content

[Bug] delegate_task subagents get 404 from opencode-go — api_key env var not loaded in child process #13678

@hernesbotnouira-dev

Description

@hernesbotnouira-dev

Bug Description

delegate_task subagents fail with 404 Page Not Found from opencode.ai when using the opencode-go provider (model minimax-m2.7). The subagent gets an HTML 404 page (not API JSON), meaning auth completely fails.

Root Cause

tools/delegate_tool.py does NOT call load_hermes_dotenv() before spawning subagents. When resolve_runtime_provider(requested=opencode-go) is called in the child, OPENCODE_GO_API_KEY is not set in the child process environment, so the API key resolves to empty string. The request goes to the web UI (no auth) and gets a 404.

Fix

Add at top of tools/delegate_tool.py:

from hermes_cli.env_loader import load_hermes_dotenv
from pathlib import Path
_hermes_home = Path.home() / .hermes
_project_env = Path(__file__).parent / .env
load_hermes_dotenv(hermes_home=_hermes_home, project_env=_project_env)

Reproduction

  1. Set OPENCODE_GO_API_KEY in ~/.hermes/.env
  2. Use opencode-go provider with minimax-m2.7
  3. Call delegate_task
  4. Subagent fails with HTML 404 page

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/agentCore agent loop, run_agent.py, prompt buildertool/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