Skip to content

The agent that grows with you

fix: satisfy the no-locked-pure-readers gate and close the DB before rmtree

Teknium8dbf07e950d0
diff --git a/hermes_state.py b/hermes_state.py
index 87651435b3f..831fcbc78dd 100644
--- a/hermes_state.py
+++ b/hermes_state.py
@@ -5978,8 +5978,8 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin)
self._db_file_application_id = disk_id
elif self._conn is not None and not self._db_file_application_id:
try:
- with self._lock:
- pragma_row = self._conn.execute("PRAGMA application_id").fetchone()
+ with self._read_ctx() as conn:
+ pragma_row = conn.execute("PRAGMA application_id").fetchone()
if pragma_row and pragma_row[0]:
self._db_file_application_id = int(pragma_row[0])
except sqlite3.Error:
diff --git a/tests/agent/test_codex_app_server_persist.py b/tests/agent/test_codex_app_server_persist.py
index 55112fa3199..46b167917c1 100644
--- a/tests/agent/test_codex_app_server_persist.py
+++ b/tests/agent/test_codex_app_server_persist.py
@@ -111,6 +111,7 @@ def test_codex_turn_persists_each_message_exactly_once():
real AIAgent._flush_messages_to_session_db to prove no #860/#42039
duplicate-write regression on the codex path."""
tmp = tempfile.mkdtemp(prefix="codex_persist_")
+ db = None
try:
db = SessionDB(Path(tmp) / "state.db")
sid = "sess-codex-once"
@@ -163,7 +164,9 @@ def test_codex_turn_persists_each_message_exactly_once():
finally:
import shutil
- shutil.rmtree(tmp)
+ if db is not None:
+ db.close()
+ shutil.rmtree(tmp, ignore_errors=True)
class TestGatewayPersistedResolution: