Skip to content

fix(agent): do not inherit api_mode when delegating across providers (#25369)#25492

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-65abd7c4
May 14, 2026
Merged

fix(agent): do not inherit api_mode when delegating across providers (#25369)#25492
teknium1 merged 1 commit into
mainfrom
hermes/hermes-65abd7c4

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

When delegate_task switches providers mid-session, the child agent inherited the parent's api_mode (e.g. codex_responses). If the new provider doesn't speak that wire protocol (e.g. delegating from Codex to OpenRouter), requests fail.

Skips api_mode inheritance when provider changes; keeps it when provider is unchanged.

Salvage of #25369 by @fu576.

Cross-provider delegation (e.g. MiniMax parent → DeepSeek child) must not
inherit the parent's api_mode, because each provider uses a different API
surface: MiniMax uses 'anthropic_messages' while DeepSeek uses
'chat_completions'. Inheriting the wrong mode causes 404 errors.

When the effective provider differs from the parent's provider, derive
api_mode from the target provider's defaults instead (None triggers
re-derivation).

Refs: Bug #20558, PR #20563
@teknium1 teknium1 merged commit f0e46c5 into main May 14, 2026
@teknium1 teknium1 deleted the hermes/hermes-65abd7c4 branch May 14, 2026 06:12
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-65abd7c4 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8319 on HEAD, 8319 on base (➖ 0)

🆕 New issues (1):

Rule Count
invalid-argument-type 1
First entries
tools/delegate_tool.py:1106: [invalid-argument-type] invalid-argument-type: Argument to `AIAgent.__init__` is incorrect: Expected `str`, found `str | None | Any`

✅ Fixed issues: none

Unchanged: 4380 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder tool/delegate Subagent delegation P2 Medium — degraded but workaround exists labels May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder 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.

3 participants