Clear Hermes session cache on token rejection retry

When the dashboard token is rejected and re-fetched, the stale
session_id was being reused, causing prompt.submit to go to a
non-existent session. Now clears both caches so the retry creates
a fresh session.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-02 19:04:36 +02:00
parent 6a259e1ef7
commit 1006d4490a
+3
View File
@@ -511,6 +511,9 @@ async def handle_hermes(
if "401" in err_str or "403" in err_str or "Unauthorized" in err_str.lower(): if "401" in err_str or "403" in err_str or "Unauthorized" in err_str.lower():
log.warning(f"[{agent.name}] Hermes token rejected, re-fetching…") log.warning(f"[{agent.name}] Hermes token rejected, re-fetching…")
_hermes_token_cache.pop(endpoint, None) _hermes_token_cache.pop(endpoint, None)
if req.conversation_id is not None:
_hermes_sessions.pop(req.conversation_id, None)
hermes_session_id = None # force session.create on retry
try: try:
token = await _fetch_hermes_token(endpoint) token = await _fetch_hermes_token(endpoint)
return await _do_chat(token) return await _do_chat(token)