Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5644,6 +5644,14 @@ def _schedule_resume_pending_sessions(self, platform=None) -> int:
for entry in candidates:
marker = entry.last_resume_marked_at or entry.updated_at
if marker is not None and (now - marker).total_seconds() > window:
# Stale marker: clear it so resume_pending flags don't
# accumulate across restarts. The next user message will
# still trigger normal reset-policy evaluation in
# get_or_create_session().
try:
self.session_store.clear_resume_pending(entry.session_key)
except Exception:
pass
continue

# Already being resumed (e.g. scheduled at startup and still
Expand Down
17 changes: 13 additions & 4 deletions hermes_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,13 @@ def _connect_and_init():
)
self._conn.row_factory = sqlite3.Row
apply_wal_with_fallback(self._conn, db_label="state.db")
# SQLite performance tuning for large state.db (1.8GB, 140K+ msgs)
# Defaults (cache_size=-2000→8MB, mmap_size=0, temp_store=0→file)
# are crippling on 3.6GB servers — dbstat takes 60s+, OOMs gateway.
# 256MB page cache + 256MB mmap fit comfortably with 1.8GB available.
self._conn.execute("PRAGMA cache_size=-262144") # 256 MB
self._conn.execute("PRAGMA mmap_size=268435456") # 256 MB
self._conn.execute("PRAGMA temp_store=2") # MEMORY
self._conn.execute("PRAGMA foreign_keys=ON")
self._init_schema()

Expand Down Expand Up @@ -2775,8 +2782,8 @@ def _do(conn):
"""INSERT INTO messages (session_id, role, content, tool_call_id,
tool_calls, tool_name, timestamp, token_count, finish_reason,
reasoning, reasoning_content, reasoning_details, codex_reasoning_items,
codex_message_items, platform_message_id, observed)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
codex_message_items, platform_message_id, observed, active)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
(
session_id,
role,
Expand All @@ -2794,6 +2801,7 @@ def _do(conn):
codex_message_items_json,
platform_message_id,
1 if observed else 0,
1,
),
)
msg_id = cursor.lastrowid
Expand Down Expand Up @@ -2866,8 +2874,8 @@ def _insert_message_rows(self, conn, session_id: str, messages: List[Dict[str, A
"""INSERT INTO messages (session_id, role, content, tool_call_id,
tool_calls, tool_name, timestamp, token_count, finish_reason,
reasoning, reasoning_content, reasoning_details, codex_reasoning_items,
codex_message_items, platform_message_id, observed)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
codex_message_items, platform_message_id, observed, active)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
(
session_id,
role,
Expand All @@ -2885,6 +2893,7 @@ def _insert_message_rows(self, conn, session_id: str, messages: List[Dict[str, A
codex_message_items_json,
platform_msg_id,
1 if msg.get("observed") else 0,
1,
),
)
inserted += 1
Expand Down
23 changes: 19 additions & 4 deletions plugins/memory/hindsight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,10 +1443,16 @@ def _start_daemon():

def system_prompt_block(self) -> str:
if self._memory_mode == "context":
if self._auto_recall:
return (
f"# Hindsight Memory\n"
f"Active (context mode). Bank: {self._bank_id}, budget: {self._budget}.\n"
f"Relevant memories are automatically injected into context."
)
return (
f"# Hindsight Memory\n"
f"Active (context mode). Bank: {self._bank_id}, budget: {self._budget}.\n"
f"Relevant memories are automatically injected into context."
f"Active (context mode, auto-recall off). Bank: {self._bank_id}, budget: {self._budget}.\n"
f"Auto-injection disabled — only manually-retained content is visible."
)
if self._memory_mode == "tools":
return (
Expand All @@ -1455,10 +1461,19 @@ def system_prompt_block(self) -> str:
f"Use hindsight_recall to search, hindsight_reflect for synthesis, "
f"hindsight_retain to store facts."
)
# hybrid mode
if self._auto_recall:
return (
f"# Hindsight Memory\n"
f"Active. Bank: {self._bank_id}, budget: {self._budget}.\n"
f"Relevant memories are automatically injected into context. "
f"Use hindsight_recall to search, hindsight_reflect for synthesis, "
f"hindsight_retain to store facts."
)
return (
f"# Hindsight Memory\n"
f"Active. Bank: {self._bank_id}, budget: {self._budget}.\n"
f"Relevant memories are automatically injected into context. "
f"Active (auto-recall off). Bank: {self._bank_id}, budget: {self._budget}.\n"
f"No automatic context injection — you must use tools to access memory. "
f"Use hindsight_recall to search, hindsight_reflect for synthesis, "
f"hindsight_retain to store facts."
)
Expand Down
Loading
Loading