hermes - ✅(Solved) Fix [Bug] delegate_task subagents get 404 from opencode-go — api_key env var not loaded in child process [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#13678Fetched 2026-04-22 08:04:46
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Timeline (top)
cross-referenced ×2

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 Action

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)

PR fix notes

PR #13679: fix(delegate): load .env before resolving subagent credentials

Description (problem / solution / changelog)

Fix

delegate_task subagents fail with 404 from providers like opencode-go because the child process does not inherit the parent's environment. When resolve_runtime_provider() is called in the subagent context, os.getenv(OPENCODE_GO_API_KEY) returns empty — the .env file was never loaded in the child process.

This adds load_hermes_dotenv() at module load time in tools/delegate_tool.py, mirroring what already exists in run_agent.py and hermes_cli/main.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)

Fixes #13678

Changed files

  • tools/delegate_tool.py (modified, +7/-0)

PR #13752: fix(tools): skip credential pool binding when delegate base_url is set

Description (problem / solution / changelog)

What does this PR do?

Fixes a bug in delegate_task where delegation.base_url is ignored when the child agent's provider matches the parent's provider ("custom"). The child's explicit base_url is silently overwritten at runtime by _swap_credential() from a shared credential pool entry that points to the parent's endpoint.

Related Issue

Fixes #13678

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tools/delegate_tool.py: Added if not override_base_url: guard before _resolve_child_credential_pool() call in _build_child_agent(). When override_base_url is set, the child is not bound to the parent's credential pool, preventing _swap_credential() from overwriting the child's explicit endpoint with the parent's URL on first API call.

How to Test

  1. Configure parent agent with provider="custom" and base_url="http://localhost:8000"
  2. Spawn subagent via delegate_task with delegation.base_url="http://localhost:8001" and delegation.provider="custom" (same provider as parent)
  3. The subagent should call http://localhost:8001/v1
  4. Before fix: first API call silently redirects to port 8000 (404 or wrong model)
  5. After fix: subagent correctly calls port 8001

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I've searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix (no unrelated commits)
  • I've run pytest tests/ -q — tests not added for this fix (would require mocking two vLLM endpoints)
  • I've added tests for my changes — same as above
  • I've tested on my platform: Debian 13

Documentation & Housekeeping

  • I've considered cross-platform impact — no OS-specific code in this change
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A (only logic change)

For New Skills

N/A — not a skill

Changed files

  • tests/tools/test_delegate.py (modified, +34/-0)
  • tools/delegate_tool.py (modified, +6/-3)

Code Example

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)
RAW_BUFFERClick to expand / collapse

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

  • #12440 (sub-agent model ignored)
  • #8037 (credential pool security)

extent analysis

TL;DR

To fix the issue, load the Hermes dotenv file in the delegate_tool.py script before spawning subagents to ensure the OPENCODE_GO_API_KEY is set.

Guidance

  • Verify that the OPENCODE_GO_API_KEY is correctly set in the ~/.hermes/.env file.
  • Add the necessary import and function call to load the Hermes dotenv file at the top of tools/delegate_tool.py, as shown in the provided fix.
  • Test the delegate_task function with the opencode-go provider and minimax-m2.7 model to ensure the subagent no longer fails with a 404 error.
  • Review related issues (#12440 and #8037) for potential connections to credential security and sub-agent model configuration.

Example

The provided fix code snippet demonstrates how to load the Hermes dotenv file:

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)

Notes

This fix assumes that the OPENCODE_GO_API_KEY is correctly set in the ~/.hermes/.env file and that the Hermes dotenv file is properly configured.

Recommendation

Apply the workaround by adding the necessary code to load the Hermes dotenv file in tools/delegate_tool.py, as this directly addresses the identified root cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING