The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): _routing_db tolerates bare test instances (object.__new__)
Tekniumcf21e28d39fe
diff --git a/gateway/session.py b/gateway/session.pyindex 78b4efa4ff2..c13183056bf 100644--- a/gateway/session.py+++ b/gateway/session.py@@ -1408,8 +1408,9 @@ class SessionStore:resolves the scope so a multiplexed profile's writes reach its ownstore."""- if self._db_pinned is not _DB_UNPINNED:- return self._db_pinned+ pinned = getattr(self, "_db_pinned", _DB_UNPINNED)+ if pinned is not _DB_UNPINNED:+ return pinnedreturn self._open_session_db_for_active_scope()@_db.setter@@ -1433,13 +1434,19 @@ class SessionStore:A pinned handle still wins, so the suites that install a fake ordisable the DB keep working unchanged."""- if self._db_pinned is not _DB_UNPINNED:- return self._db_pinned+ pinned = getattr(self, "_db_pinned", _DB_UNPINNED)+ if pinned is not _DB_UNPINNED:+ return pinnedhome = getattr(self, "_routing_home", None)- if home is None:- return self._dbtry:+ if home is None:+ return self._dbreturn self._open_session_db_for_active_scope(db_path=home / "state.db")+ except AttributeError:+ # Bare test instances (object.__new__) lack _routing_home AND the+ # handle cache behind the _db property; behave like main's old+ # getattr(self, "_db", None) contract and report no DB.+ return getattr(self, "_db_pinned", None) if getattr(self, "_db_pinned", _DB_UNPINNED) is not _DB_UNPINNED else Noneexcept Exception:return None@@ -1511,8 +1518,9 @@ class SessionStore:store from it makes every caller agree on one file per sessionwithout threading scope through each call site."""- if self._db_pinned is not _DB_UNPINNED:- return self._db_pinned+ pinned = getattr(self, "_db_pinned", _DB_UNPINNED)+ if pinned is not _DB_UNPINNED:+ return pinnedprofile = self._named_profile_for_key(session_key)if profile is None:# No named owner — the ambient store is authoritative, exactly as