hermes - 💡(How to fix) Fix delegate_task sends API key to wrong provider endpoint (OpenRouter key → OpenAI)

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…

Error Message

delegate_task sends the OpenRouter API key (sk-or-v1-***) to the OpenAI API endpoint (https://api.openai.com/v1/chat/completions), resulting in a 401 error: Error code: 401 - { 'error': { 4. Observe 401 error with OpenRouter key sent to OpenAI endpoint

  • The error persists across gateway restarts
  • The model field in the error shows gpt-5.5 (not the configured qwen/qwen3.7-max)

Fix Action

Fix / Workaround

Impact

  • Blocking: Cannot use live subagent execution with OpenRouter
  • Workaround: Execute tasks directly in parent agent (loses parallelization)
  • Severity: High — breaks core multi-agent workflow feature

Code Example

model:
  default: qwen/qwen3-asr-flash-2026-02-10
  provider: openrouter
  base_url: ''
providers: {}

delegation:
  model: qwen/qwen3.7-max
  provider: openrouter
  base_url: ''
  api_key: ''

---

model:
  default: gpt-5.5
  provider: openai-codex
  base_url: https://chatgpt.com/backend-api/codex

delegation:
  model: qwen/qwen3.7-max
  provider: openrouter
  base_url: ''
  api_key: ''

---

OPENROUTER_API_KEY=sk-or-v1-***

---

Error code: 401 - {
  'error': {
    'message': 'Incorrect API key provided: sk-or-v1-***. 
                You can find your API key at https://platform.openai.com/account/api-keys.',
    'type': 'invalid_request_error',
    'code': 'invalid_api_key'
  }
}
RAW_BUFFERClick to expand / collapse

Bug Report: delegate_task sends API key to wrong provider endpoint

Environment

  • Hermes version: Latest (as of 2026-05-29)
  • OS: macOS 26.5
  • Profile: default + pi-dev-ops

Configuration

~/.hermes/config.yaml (default profile)

model:
  default: qwen/qwen3-asr-flash-2026-02-10
  provider: openrouter
  base_url: ''
providers: {}

delegation:
  model: qwen/qwen3.7-max
  provider: openrouter
  base_url: ''
  api_key: ''

~/.hermes/profiles/pi-dev-ops/config.yaml

model:
  default: gpt-5.5
  provider: openai-codex
  base_url: https://chatgpt.com/backend-api/codex

delegation:
  model: qwen/qwen3.7-max
  provider: openrouter
  base_url: ''
  api_key: ''

~/.hermes/.env

OPENROUTER_API_KEY=sk-or-v1-***

Expected Behavior

When delegate_task is called, it should:

  1. Read the delegation.provider config (set to openrouter)
  2. Read the delegation.model config (set to qwen/qwen3.7-max)
  3. Send the request to OpenRouter's API endpoint using the OPENROUTER_API_KEY

Actual Behavior

delegate_task sends the OpenRouter API key (sk-or-v1-***) to the OpenAI API endpoint (https://api.openai.com/v1/chat/completions), resulting in a 401 error:

Error code: 401 - {
  'error': {
    'message': 'Incorrect API key provided: sk-or-v1-***. 
                You can find your API key at https://platform.openai.com/account/api-keys.',
    'type': 'invalid_request_error',
    'code': 'invalid_api_key'
  }
}

Reproduction Steps

  1. Set delegation.provider = openrouter in config.yaml
  2. Set OPENROUTER_API_KEY in .env
  3. Call delegate_task with any goal
  4. Observe 401 error with OpenRouter key sent to OpenAI endpoint

Additional Context

  • The main agent correctly uses OpenRouter (model: qwen/qwen3-asr-flash-2026-02-10)
  • Only delegate_task (subagent spawning) exhibits this routing bug
  • Tried: hermes config set delegation.provider openrouter, restarting gateway
  • The error persists across gateway restarts
  • The model field in the error shows gpt-5.5 (not the configured qwen/qwen3.7-max)

Hypothesis

The delegate_task implementation may be:

  1. Ignoring the delegation.provider config and defaulting to openai
  2. Using the main agent's model (gpt-5.5) instead of delegation.model
  3. Not resolving the API key through the credential pool correctly for subagents

Impact

  • Blocking: Cannot use live subagent execution with OpenRouter
  • Workaround: Execute tasks directly in parent agent (loses parallelization)
  • Severity: High — breaks core multi-agent workflow feature

Suggested Fix

Ensure delegate_task reads from delegation.* config keys (not model.*) and routes API calls to the correct provider endpoint based on delegation.provider.

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

hermes - 💡(How to fix) Fix delegate_task sends API key to wrong provider endpoint (OpenRouter key → OpenAI)