The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: log swallowed reclaim failures + pin ContextVar dispatch invariant (review follow-up for #91217)
Teknium7d1c9aeab739
diff --git a/gateway/run.py b/gateway/run.pyindex 581162a05b8..9976234f958 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -14072,6 +14072,17 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew# parameter, and a keyword call would TypeError into the# failure branch — turning a passing suite into a silent# no-op watcher. Arity is probed above.+ #+ # INVARIANT (do not weaken): this task is created inside+ # ``_profile_runtime_scope(profile_home)`` but typically RUNS+ # after the scope exits. It still sees the profile's home and+ # secret scope only because ``set_hermes_home_override`` and+ # ``set_secret_scope`` are ContextVar-based — ensure_future+ # copies the current Context into the Task. If either seam is+ # ever migrated to a thread-local or module global, secondary-+ # profile handoffs silently regress to primary-config delivery+ # (the exact bug fixed in #91217) while still recording+ # handoff_state='completed'.inflight[session_id] = asyncio.ensure_future(_dispatch(row, session_id, session_db, profile_name))diff --git a/hermes_state.py b/hermes_state.pyindex 7c20af3dbd6..3da58aa600d 100644--- a/hermes_state.py+++ b/hermes_state.py@@ -15247,6 +15247,13 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin)try:return self._execute_write(_do) or []except Exception:+ # Swallow but never silently: a persistently failing reclaim+ # leaves poisonous 'running' rows in place (sessions that can+ # never hand off again), so the operator needs a trace of it.+ logger.warning(+ "reclaim_stale_running_handoffs failed; stranded 'running' "+ "handoff rows (if any) were left in place", exc_info=True,+ )return []