Skip to content

fix(delegate): inherit parent api_key when delegation.base_url set without delegation.api_key#19741

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8c54fd4a
May 4, 2026
Merged

fix(delegate): inherit parent api_key when delegation.base_url set without delegation.api_key#19741
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8c54fd4a

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented May 4, 2026

Salvage of #15853 by @briandevans onto current main.

Summary

When delegation.base_url is configured without delegation.api_key, the child agent was falling back to OPENAI_API_KEY from the env instead of inheriting the parent's resolved key. Parents running on non-OpenAI providers (Anthropic, Kimi, MiniMax, DashScope) saw their children fail auth because the inherited key was the wrong one.

Return api_key=None from _resolve_delegation_credentials when not configured, so _build_child_agent uses effective_api_key = override_api_key or parent_api_key — the parent's key, with explicit override still respected.

Conflict resolution during salvage

Main's docstring was updated for the related provider-resolution path since the PR opened. Merged docstrings so both code paths are documented. Updated two existing tests that locked in the old OPENAI_API_KEY-fallback behavior to expect the new inheritance semantics.

Changes

  • tools/delegate_tool.py: return api_key=None for parent inheritance, update docstring (+6/-9)
  • tests/tools/test_delegate.py: two existing tests renamed/rewritten for the new behavior

Validation

scripts/run_tests.sh tests/tools/test_delegate.py -k direct_endpoint -> 4 passed

Original PR: #15853
Fixes: #15810

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@teknium1 teknium1 merged commit 0b5fd40 into main May 4, 2026
5 of 10 checks passed
@teknium1 teknium1 deleted the hermes/hermes-8c54fd4a branch May 4, 2026 12:18
@alt-glitch alt-glitch added type/bug Something isn't working tool/delegate Subagent delegation P2 Medium — degraded but workaround exists labels May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] delegate_task: api_key falls back to OPENAI_API_KEY instead of provider credential chain when delegation.base_url is set

3 participants