hermes - ✅(Solved) Fix [Bug]: [subagent] Fallback model uses parent's base_url instead of fallback's base_url [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#24782Fetched 2026-05-14 03:51:51
View on GitHub
Comments
0
Participants
1
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
labeled ×5cross-referenced ×2referenced ×1

Error Message

This results in a 400 error because the local gateway doesn't recognize the Error Log [subagent-0] 📝 Error: Malformed publisher model (model: 'sensenova-6.7-flash-lite') This results in a 400 error because the local gateway doesn't recognize the Error Log [subagent-0] 📝 Error: Malformed publisher model (model: 'sensenova-6.7-flash-lite')

Additional Logs / Traceback (optional)

Root Cause

This results in a 400 error because the local gateway doesn't recognize the model name format.

Fix Action

Fixed

PR fix notes

PR #24819: fix(fallback): deep-copy fallback chain + prefer entry base_url for subagents

Description (problem / solution / changelog)

Summary

When a subagent spawned via delegate_task falls back to a secondary model, it uses the parent agent's base_url instead of the fallback entry's configured base_url. This causes HTTP 400 errors when the parent's local gateway doesn't recognize the fallback model's name format.

Root Cause

Two issues:

  1. Shared mutable chain: delegate_tool.py:1067 passed the parent's _fallback_chain list by reference. If the parent or any future normalisation pass mutated the entry dicts (e.g. stripping base_url), the subagent would silently lose its fallback configuration. The [] or None pattern also dropped empty chains.

  2. Sequential assignment: _try_activate_fallback (run_agent.py:8731-8733) updates self.model before self.base_url. If an exception occurs between these assignments, the agent enters a corrupted state with the fallback model name but the parent's base URL.

Changes

tools/delegate_tool.py

  • Added top-level import copy
  • Deep-copy _fallback_chain before passing to child AIAgent(), ensuring parent and subagent have independent chain instances
  • Fixed [] or None falsy-list trap: empty chains now correctly propagate as None

run_agent.py

  • When a fallback entry specifies base_url, prefer it directly over the resolved client's base_url — the entry is authoritative
  • Added diagnostic logging.warning when the entry URL and resolved client URL diverge (URL normalisation drift guard)

Testing

  1. Configure model.base_url as a local gateway (http://127.0.0.1:8081)
  2. Add fallback_providers with a remote base_url (e.g. https://token.sensenova.cn/v1)
  3. Spawn a subagent via delegate_task
  4. Force primary model to fail
  5. Assert subagent fallback logs show the remote URL, not 127.0.0.1

Validation

  • ruff: 0 issues on both files
  • Fallback chain entries confirmed as plain YAML dicts (safe for deepcopy)

Fixes #24782

Changed files

  • run_agent.py (modified, +21/-1)
  • tools/delegate_tool.py (modified, +8/-1)

PR #24865: test(run_agent): add fallback base_url tests for #24782

Description (problem / solution / changelog)

Cover: skip dedup when base_url differs, subagent fallback inheritance, client_kwargs updated post-activation, provider=custom with explicit_base_url

Changed files

  • .hermes/plans/2026-05-13_135900-fix-readme.md (added, +81/-0)
  • tests/run_agent/test_subagent_fallback_base_url.py (added, +276/-0)

Code Example

-

---
RAW_BUFFERClick to expand / collapse

Bug Description

When a subagent spawned via delegate_task falls back to a secondary model, it incorrectly uses the parent agent's base_url instead of the fallback entry's configured base_url.

Expected Behavior

When fallback activates, the subagent should switch to the fallback entry's
full configuration including base_url, api_key, and model.

Actual Behavior

The subagent uses:
- Parent's base_url: http://127.0.0.1:8081
- Fallback's model: sensenova-6.7-flash-lite

This results in a 400 error because the local gateway doesn't recognize the
model name format.

Configuration

config.yaml:
yaml
model:
  base_url: http://127.0.0.1:8081
  provider: custom
  default: google/gemini-3.1-flash-lite-preview

fallback_providers:
  - provider: custom
    base_url: https://token.sensenova.cn/v1
    api_key: sk-xxx
    model: deepseek-v4-flash
  - provider: custom
    base_url: https://token.sensenova.cn/v1
    api_key: sk-xxx
    model: sensenova-6.7-flash-lite


Error Log


[subagent-0] ⚠️  API call failed (attempt 1/1): BadRequestError [HTTP 400]
[subagent-0]    🔌 Provider: custom  Model: sensenova-6.7-flash-lite
[subagent-0]    🌐 Endpoint: http://127.0.0.1:8081
[subagent-0]    📝 Error: Malformed publisher model (model: 'sensenova-6.7-flash-lite')
                       for the 'openapi' request endpoint ID;
                       expected '<publisher>/<model>'.


Root Cause Analysis

1. Subagent initialization (delegate_tool.py:1067-1102):
   python
   parent_fallback = getattr(parent_agent, "_fallback_chain", None) or None
   child = AIAgent(
       base_url=effective_base_url,  # inherits parent's 127.0.0.1:8081
       ...
       fallback_model=parent_fallback,  # passes full fallback chain
   )


2. Fallback activation (run_agent.py:8757-8778):
   python
   fb_base_url_hint = (fb.get("base_url") or "").strip() or None
   fb_client, _resolved_fb_model = resolve_provider_client(
       fb_provider, model=fb_model, raw_codex=True,
       explicit_base_url=fb_base_url_hint,  # should be token.sensenova.cn
       explicit_api_key=fb_api_key_hint,
   )


3. The issue: resolve_provider_client() for provider="custom" with
   explicit_base_url should work correctly, but the subagent appears to
   either:
   - Not trigger the fallback path properly
   - Or the fallback chain entries are being stripped of base_url/api_key
     during subagent initializatio

Note: http://127.0.0.1:8081/ is a script service I wrote myself to convert requests for Google Vertex, and it works fine and can be requested normally.

Steps to Reproduce

  1. Configure parent agent with base_url: http://127.0.0.1:8081 2. Configure fallback_providers with different base_url (e.g., token.sensenova.cn) 3. Spawn a subagent via delegate_task 4. Make the primary model fail (e.g., by using a non-existent model or rate limit) 5. Observe that fallback uses parent's base_url instead of fallback's 6. Related Code
  • tools/delegate_tool.py:1067-1102 (subagent fallback chain inheritance)
    • run_agent.py:8697-8850 (_try_activate_fallback implementation)
    • agent/auxiliary_client.py:2817-2859 (resolve_provider_client for custom provider)

Expected Behavior

When fallback activates, the subagent should switch to the fallback entry's full configuration including base_url, api_key, and model.

Actual Behavior

The subagent uses: - Parent's base_url: http://127.0.0.1:8081 - Fallback's model: sensenova-6.7-flash-lite

This results in a 400 error because the local gateway doesn't recognize the
model name format.

Configuration

config.yaml:
yaml
model:
  base_url: http://127.0.0.1:8081
  provider: custom
  default: google/gemini-3.1-flash-lite-preview

fallback_providers:
  - provider: custom
    base_url: https://token.sensenova.cn/v1
    api_key: sk-xxx
    model: deepseek-v4-flash
  - provider: custom
    base_url: https://token.sensenova.cn/v1
    api_key: sk-xxx
    model: sensenova-6.7-flash-lite


Error Log


[subagent-0] ⚠️  API call failed (attempt 1/1): BadRequestError [HTTP 400]
[subagent-0]    🔌 Provider: custom  Model: sensenova-6.7-flash-lite
[subagent-0]    🌐 Endpoint: http://127.0.0.1:8081
[subagent-0]    📝 Error: Malformed publisher model (model: 'sensenova-6.7-flash-lite')
                       for the 'openapi' request endpoint ID;
                       expected '<publisher>/<model>'.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

N/A (CLI only)

Debug Report

-

Operating System

wsl

Python Version

3.11.15

Hermes Version

Hermes Agent v0.13.0 (2026.5.7)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

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