Skip to content
Open
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
26 changes: 26 additions & 0 deletions agent/system_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,32 @@ def build_system_prompt_parts(agent: Any, system_message: Optional[str] = None)
if user_block:
volatile_parts.append(user_block)

# ── Session Handoff: auto-load continuity files ──
# Reads all *.md files from ~/.hermes/session_handoff/ at session build
# time. Allows continuity between sessions without the user needing to
# explicitly reference files or paste context into chat.
# Cache-safe: read once at build_system_prompt_parts() time, byte-stable
# for the session lifetime (same tier as memory and user profile).
try:
from pathlib import Path as _SHPath
from hermes_constants import get_hermes_home as _SHget_hh
_sh_dir = _SHPath(_SHget_hh()) / "session_handoff"
if _sh_dir.is_dir():
_sh_parts = []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please enforce a per-file or aggregate character budget here. Existing context sources use the bounded truncation path in agent/prompt_builder.py; this unbounded glob can consume the session context window.

for _sh_f in sorted(_sh_dir.glob("*.md")):
if _sh_f.is_file():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inserts arbitrary file content directly into the system prompt. Existing context sources call _scan_context_content() first (agent/prompt_builder.py:50-66); route handoff content through the same scanner before appending it.

_sh_content = _sh_f.read_text(encoding="utf-8", errors="replace")
if _sh_content.strip():
_sh_parts.append(
f"--- Handoff: {_sh_f.name} ---\n{_sh_content.strip()}"
)
if _sh_parts:
volatile_parts.append(
"# Session Handoff\n" + "\n\n".join(_sh_parts)
)
except Exception:
pass

# External memory provider system prompt block (additive to built-in)
if agent._memory_manager:
try:
Expand Down