mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-24 05:41:40 +00:00
fix(gateway): isinstance-guard string-form 429 error body
When a non-Anthropic provider (e.g. Morpheus proxy) returns a 429 with
`{"error": "Too Many Requests"}` instead of the expected
`{"error": {"type": ...}}` dict, _err_body.json().get("error", {})
returns the raw string and the next .get("type") line crashes with
AttributeError, taking down the message handler.
Guard with isinstance(_err_json, dict) so non-dict error bodies fall
through to the generic rate-limit hint.
Salvaged from PR #2587 by @KiraKatana. The PR's fallback-config
`base_url`/`api_key_env` fix was already implemented independently
on main (run_agent.py:8759-8780) with additional aliases and Ollama
Cloud host handling, so only the gateway guard is cherry-picked.
Co-authored-by: KiraKatana <kira.ops@proton.me>
This commit is contained in:
parent
e0e7397c32
commit
23ac522d37
2 changed files with 3 additions and 0 deletions
|
|
@ -7991,6 +7991,8 @@ class GatewayRunner:
|
|||
try:
|
||||
if _err_body is not None:
|
||||
_err_json = _err_body.json().get("error", {})
|
||||
if not isinstance(_err_json, dict):
|
||||
_err_json = {}
|
||||
except Exception:
|
||||
pass
|
||||
if _err_json.get("type") == "usage_limit_reached":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue