Detect PC offline gaps across Hermes sessions β Know when your user went to sleep, when they're back from a break, or when it's a brand new day.
Your PC isn't 24/7. You turn it off at night, on in the morning. Without continuity detection:
| Scenario | Without This Skill | With This Skill |
|---|---|---|
| 10 PM β 6 AM (8h gap) | "Haan Boss, bolo?" | "Wapas aaye Boss! π 8h gap tha. Raat ko so gaye the kya?" |
| 2 PM β 4 PM (2h break) | "Haan Boss, bolo?" | "Welcome back (2h baad). Continue karein?" |
| First ever session | "Haan Boss, bolo?" | "Shubh prabhat Boss! π Pehli baar mil rahe hain?" |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TYPICAL USER DAY (Not a 24/7 Server) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 10:30 PM β "Gym jaa raha hoon, kal milte hain" β
β 10:35 PM β PC SHUTDOWN β
β 6:30 AM β PC BOOT β
β 6:35 AM β "Haan bolo" (expects fresh context) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Issue | Impact |
|---|---|
| False Continuity | Agent thinks last message was "5 minutes ago" when it was actually 8+ hours ago |
| Context Pollution | Night conversation context incorrectly applied to morning session |
| Tone Deaf Responses | "Haan Boss, bolo?" at 6 AM after 8h sleep feels robotic |
| Memory Leakage | Personal/evening topics bleed into professional morning context |
| No Session Boundaries | Can't distinguish "continue previous task" vs "start fresh" |
- Hermes runs on user's local PC (not a cloud server)
- PC powers off/on daily β memory persists but time doesn't
- Agent has no concept of "wall clock time" between sessions
- SQLite memory stores timestamps but nothing reads them at session start
This skill bridges the gap by:
- Reading timestamps from Hermes SQLite memory at session start
- Calculating real-world gap (current_time - last_activity_time)
- Categorizing intelligently with configurable thresholds:
< 4 hoursβCONTINUOUS(short break, maintain context)4-12 hoursβBROKEN(overnight, acknowledge gap, fresh greeting)> 12 hoursβFRESH(new day, full context reset)
- Injecting context into agent prompt automatically
- Recording new timestamps for next session
- π Automatic gap detection β Compares last message timestamp with current time
- π§ Smart categorization β Continuous / Broken / Fresh with configurable thresholds
- π¬ Contextual greetings β Hindi/English mixed natural responses
- ποΈ Persistent storage β Uses Hermes SQLite memory (survives PC restarts)
- π Zero-config plugin β Auto-loads on session start via Hermes hook
- π§ͺ Fully tested β 8 comprehensive test cases covering all edge cases
# Clone the skill
git clone https://github.com/jojo535/session-continuity-detector.git
cd session-continuity-detector
# Install via Hermes (auto-copies to ~/.hermes/skills/)
hermes skill install .# Copy to your Hermes skills directory
cp -r session-continuity-detector ~/.hermes/skills/core/
# Enable the plugin in config.yaml
echo "
plugins:
enabled:
- session-continuity
" >> ~/.hermes/config.yamlpip install -e .from session_continuity import SessionContinuityDetector
detector = SessionContinuityDetector()
# Check continuity at session start
status = detector.check_continuity()
if status.is_fresh:
print("π
Fresh session - new day!")
elif status.is_broken:
print("π Overnight gap detected")
elif status.is_continuous:
print("π¬ Continuous session")
# Use the suggested greeting
print(status.suggested_greeting)
# Record each user message to keep timestamps fresh
detector.record_message()detector = SessionContinuityDetector(
gap_threshold_hours=4.0, # >4h = likely overnight
fresh_threshold_hours=12.0, # >12h = new day
memory_key_prefix="my_app" # Custom prefix for multi-app
)# Check current continuity status
python -m session_continuity --check
# Record activity (call on each user message)
python -m session_continuity --record
# Reset session (for testing)
python -m session_continuity --resetAdd to your ~/.hermes/config.yaml:
plugins:
enabled:
- session-continuity
- a2a
- spotify
# Optional: Customize thresholds
session_continuity:
gap_threshold_hours: 4.0
fresh_threshold_hours: 12.0
auto_record_on_message: true
inject_into_prompt: true| Threshold | Default | Meaning |
|---|---|---|
gap_threshold_hours |
4.0 | Hours after which session = "broken" (overnight) |
fresh_threshold_hours |
12.0 | Hours after which session = "fresh" (new day) |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Session Start β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β on_session_start Hook β
β (Auto-fired by Hermes plugin system) β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SessionContinuityDetector.check() β
β 1. Read last_message_ts, last_activity_ts from SQLite β
β 2. Calculate gap = now - max(last_msg, last_activity) β
β 3. Categorize: continuous / broken / fresh β
β 4. Generate contextual greeting β
β 5. Record new session_start_ts β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Context Injected to Agent β
β "[SESSION CONTINUITY: BROKEN] Last activity 8h ago. β
β Suggested: Wapas aaye Boss! π 8h gap tha..." β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Table: hermes_agent_memory
key | value | updated_at
--------------------------------|----------|-----------
session_last_message_ts | 1787737113 | 1787737113
session_last_activity_ts | 1787737113 | 1787737113
session_continuity_status | broken | 1787737113
session_gap_hours | 8.00 | 1787737113
session_start_ts | 1787769513 | 1787769513detector = SessionContinuityDetector(
gap_threshold_hours: float = 4.0,
fresh_threshold_hours: float = 12.0,
memory_key_prefix: str = "session"
)| Method | Returns | Description |
|---|---|---|
check_continuity() |
ContinuityStatus |
Main detection β call at session start |
record_activity() |
None |
Record generic activity timestamp |
record_message() |
None |
Record user message (updates both timestamps) |
get_last_timestamps() |
Tuple[int, int] |
Returns (last_msg_ts, last_activity_ts) |
reset_session() |
None |
Force fresh session (testing) |
@dataclass
class ContinuityStatus:
is_continuous: bool # < gap_threshold
is_broken: bool # gap_threshold <= gap < fresh_threshold
is_fresh: bool # >= fresh_threshold OR first session
gap_hours: float # Hours since last activity
last_message_ts: int # Unix timestamp
last_activity_ts: int # Unix timestamp
current_ts: int # Current Unix timestamp
status_label: str # "continuous" | "broken" | "fresh"
suggested_greeting: str # Ready-to-use greeting string# Run full test suite
python tests/test_session_continuity.py
# Expected output:
# ============================================================
# SESSION CONTINUITY DETECTOR - TEST SUITE
# ============================================================
# π§ͺ Test 1: Fresh session (no history)
# β
fresh: Shubh prabhat Boss! π
Pehli baar mil rahe hain?
#
# π§ͺ Test 2: Continuous - short gap (30 min)
# β
continuous: Wapas aaye (30 min baad). Kya chal raha hai? (gap: 0.50h)
#
# π§ͺ Test 3: Continuous - medium gap (2 hours)
# β
continuous: Welcome back (2.0h baad). Continue karein? (gap: 2.00h)
#
# π§ͺ Test 4: Broken - overnight gap (8 hours)
# β
broken: Wapas aaye Boss! π 8.0 hours gap tha. Raat ko so gaye the kya? (gap: 8.00h)
#
# π§ͺ Test 5: Fresh - new day gap (16 hours)
# β
fresh: Shubh prabhat Boss! π
16.0 hours pehle baat hui thi. Naya din, naya start? (gap: 16.00h)
#
# π§ͺ Test 6: Edge cases at thresholds
# β
4h exactly: broken
# β
12h exactly: fresh
#
# π§ͺ Test 7: Record message updates timestamps
# β
Timestamps updated: msg=1787737457, activity=1787737457
#
# π§ͺ Test 8: Persistence across instances
# β
Persistence works: continuous (gap: 0.0000h)
#
# ============================================================
# β
ALL TESTS PASSED!
# ============================================================session-continuity-detector/
βββ scripts/
β βββ session_continuity.py # Core detector class
βββ tests/
β βββ test_session_continuity.py # Test suite (8 tests)
βββ docs/
β βββ INTEGRATION.md # Hermes integration guide
βββ examples/
β βββ basic_usage.py # Simple example
β βββ hermes_plugin.py # Plugin integration
β βββ custom_thresholds.py # Custom config example
βββ SKILL.md # Hermes skill manifest
βββ README.md # This file
βββ LICENSE # MIT License
βββ pyproject.toml # Package metadata
βββ requirements.txt # Dependencies (none!)
The skill includes a ready-to-use Hermes plugin at plugins/session-continuity/:
# plugins/session-continuity/__init__.py
from hermes_cli.plugins import PluginManager
from session_continuity import SessionContinuityDetector
def on_session_start(session_id: str, model: str = "", platform: str = "", **kwargs):
detector = SessionContinuityDetector()
status = detector.check_continuity()
detector.record_message() # Update timestamp
if status.is_fresh or status.is_broken or (status.is_continuous and status.gap_hours > 0.5):
return {"context": f"[SESSION CONTINUITY: {status.status_label.upper()}] {status.suggested_greeting}"}
return {}
def register(plugin_manager: PluginManager):
plugin_manager.register_hook("on_session_start", on_session_start)
return TrueAuto-loads when added to config.yaml plugins.enabled.
| Use Case | How It Helps |
|---|---|
| Daily AI assistant | Knows when you wake up vs quick break |
| Coding sessions | Distinguishes "continue where left off" vs "new task" |
| Learning streaks | Tracks actual daily continuity |
| Multi-device sync | Shared memory via Hermes SQLite |
- Fork the repo
- Create feature branch:
git checkout -b feature/amazing-feature - Run tests:
python tests/test_session_continuity.py - Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Open PR
MIT License β see LICENSE for details.
- Built for Hermes Agent by Nous Research
- Uses SQLite for persistent memory
- Inspired by real-world PC usage patterns (not 24/7 servers!)
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Hermes Docs: https://hermes-agent.nousresearch.com/docs
Made with β€οΈ for Hermes Agent users who actually sleep