Skip to content

fix(gateway): detect prior sessions from disk in has_any_sessions() - #352

Closed
Farukest wants to merge 1 commit into
NousResearch:mainfrom
Farukest:fix/has-any-sessions-single-platform
Closed

fix(gateway): detect prior sessions from disk in has_any_sessions()#352
Farukest wants to merge 1 commit into
NousResearch:mainfrom
Farukest:fix/has-any-sessions-single-platform

Conversation

@Farukest

@Farukest Farukest commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

has_any_sessions() returned len(self._entries) > 1, but _entries is keyed by session_key and each platform+chat combination has exactly one key. When a session resets, the old entry is replaced under the same key, so the count never grows. Single-platform users always got False after a reset, triggering the "first message ever" onboarding on every new session.

Added a _loaded_from_disk flag that is set in _ensure_loaded() when sessions.json contains at least one entry. has_any_sessions() now returns True when either the flag is set or there are multiple keys, correctly detecting returning users regardless of how many platforms they use.

Tests

Added TestHasAnySessions to tests/gateway/test_session.py with 6 tests:

  • Fresh install with no entries → False
  • First session just created, not yet persisted → False
  • Single-platform user after reset (loaded from disk) → True
  • Multi-platform user → True regardless of disk state
  • _loaded_from_disk flag set when sessions.json has data
  • _loaded_from_disk stays False for empty sessions.json

Closes #351

@teknium1

teknium1 commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for the detailed issue report and this PR, @Farukest. We went with PR #370's approach (using the SQLite database's session count) since the DB is the authoritative source for session history and avoids adding a new flag. Your analysis of the bug was spot-on and helped us evaluate both solutions. Closing this one in favor of #370.

@teknium1 teknium1 closed this Mar 4, 2026
teknium1 added a commit that referenced this pull request Mar 5, 2026
…guard

Authored by Farukest. Fixes #385.

Replaces startswith() with Path.is_relative_to() in _check_structure()
symlink escape check — same fix pattern as skill_view() (PR #352).
Prevents symlinks escaping to sibling directories with shared name prefixes.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…n in skills_guard

Authored by Farukest. Fixes NousResearch#385.

Replaces startswith() with Path.is_relative_to() in _check_structure()
symlink escape check — same fix pattern as skill_view() (PR NousResearch#352).
Prevents symlinks escaping to sibling directories with shared name prefixes.
@HowdyDooToYou

Copy link
Copy Markdown

✅ Dream-Cycle Memory Bridge Implemented (BG-3)

As part of the OpenClaw workspace automation work, a dream-memory-bridge.sh script has been created and deployed. This bridges the nightly dream cycle (DREAMS.md) to actionable memory insights.


📋 Extracted Insights (Live Evidence from First Run)

Scan Stats: 29 total dream entries, 21 within last 7 days, 10 insight lines extracted with keyword matches.

Theme Frequency Analysis

Keyword Occurrences
found 3
realized 1
need to 2
issue 1
bug 4

Key Insights Extracted

Lesson: read-only first, then escalate — Dreams keep returning to the Porkbun/DNS incident: "I realized I'd been reaching for the write operations before understanding the read state."

Contact-form / MX records — Multiple dream entries reference the DNS incident thread with recurring imagery of MX records, validation errors, authentication tokens, and env var tracing.

Memory consolidation and entropy — Dreams reference "entropy at 0.20," memory being "trimmed," and consolidation as a "tide exposing a bloated corner" — showing the agent's awareness of its own decay/consolidate subsystems.

Cron and scheduling"missed cron task resurfacing, urging me to recover forgotten promises" — the dream layer is self-aware of scheduling gaps.

Recurring temporal confusion — Dates cycling (June 11-20) through dreams like a "loop of temporary files" suggests the dream cycle needs better date awareness.


🔧 Implementation

Item Status
Script: scripts/dream-memory-bridge.sh ✅ Created
Cron: 0 8 * * * (1hr after dream cycle 07:00) ✅ Deployed
Output: memory/dream-insights/latest.md ✅ Generated
Safety: Does NOT modify MEMORY.md ✅ Human review gate in place

Safety Design

The bridge outputs to memory/dream-insights/latest.md only — it never writes to MEMORY.md automatically. This respects the human-in-the-loop architecture: insights are surfaced for review, not injected into long-term memory without human approval.

waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…n in skills_guard

Authored by Farukest. Fixes NousResearch#385.

Replaces startswith() with Path.is_relative_to() in _check_structure()
symlink escape check — same fix pattern as skill_view() (PR NousResearch#352).
Prevents symlinks escaping to sibling directories with shared name prefixes.
cermm added a commit to cermm/hermes-agent that referenced this pull request Aug 1, 2026
cermm added a commit to cermm/hermes-agent that referenced this pull request Aug 1, 2026
cermm added a commit to cermm/hermes-agent that referenced this pull request Aug 1, 2026
cermm added a commit to cermm/hermes-agent that referenced this pull request Aug 1, 2026
cermm added a commit to cermm/hermes-agent that referenced this pull request Aug 1, 2026
@cermm

cermm commented Aug 1, 2026

Copy link
Copy Markdown

Publication evidence for the reviewed #352 integration candidate:

The branch update was a normal fast-forward only. This evidence does not merge or close PR #9 or #352.

cermm added a commit to cermm/hermes-agent that referenced this pull request Aug 1, 2026
NousResearch#401)

Exact owned-fork merge authorized by umbrella-auth-1533030101162266695 after semantic, security and immutable PASS plus 49 authoritative CI checks (44 success, 5 policy skips), exact head/base and clean mergeability readback. No NousResearch upstream mutation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

has_any_sessions() always returns False for single-platform users, causing repeated onboarding

4 participants