Skip to content

feat: session handoff — auto-load continuity files between sessions - #61840

Open
k-QRedHacker wants to merge 1 commit into
NousResearch:mainfrom
k-QRedHacker:feat/session-handoff
Open

feat: session handoff — auto-load continuity files between sessions#61840
k-QRedHacker wants to merge 1 commit into
NousResearch:mainfrom
k-QRedHacker:feat/session-handoff

Conversation

@k-QRedHacker

Copy link
Copy Markdown

Session Handoff: Auto-Load Continuity Files Between Sessions

This PR adds a lightweight session handoff mechanism to Hermes Agent. Users can place *.md files in ~/.hermes/session_handoff/ before starting a new session (/new), and the agent automatically reads and incorporates them into its system prompt.

What This Does

  • Scans ~/.hermes/session_handoff/ for all *.md files at session build time
  • Injects their content into volatile_parts (same tier as memory and user profile)
  • Provides continuity between sessions without the user needing to explicitly reference files or paste context into chat

Cache Safety

Does NOT break prompt caching: files are read once at build_system_prompt_parts() time. The result is byte-stable for the session lifetime — same behavior as existing memory and user profile injection.

File Changed

File Change Lines
agent/system_prompt.py Session Handoff injection in build_system_prompt_parts() +26

Total: 1 file, 26 insertions.

Note

This was originally bundled inside #61731/#61738 alongside the time awareness feature. It has been separated into its own PR per reviewer feedback (#61837 is the clean time-awareness-only PR).

Reads all *.md files from ~/.hermes/session_handoff/ at session build
time and injects them into the system prompt volatile_parts tier.

Use case: place handoff notes before starting a new session (/new).
The agent automatically reads and incorporates them, providing
continuity without explicit user action.

Cache safety: read once at build_system_prompt_parts() time,
byte-stable for the session lifetime. Same tier as memory and
user profile — volatile at session boundary, stable within.

Co-Authored-By: Claw F (量子红客组织)
@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jul 10, 2026

@teknium1 teknium1 left a comment

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.

Thanks for separating the session-handoff proposal into a focused change. The feature is not already present on current main: agent/system_prompt.py:457-500 has no handoff source.

Problems

  • The new raw read at agent/system_prompt.py:484 bypasses _scan_context_content() (agent/prompt_builder.py:50-66). Existing tests show the scanner blocks prompt-injection text before system-prompt insertion (tests/agent/test_prompt_builder.py:69-73); this path would inject it verbatim.
  • The loop loads every *.md file with no per-file or aggregate cap, unlike existing context sources, whose cap is defined in agent/prompt_builder.py:1171-1219.
  • The PR changes prompt assembly but adds no coverage for loading, profile scoping, injection blocking, truncation, or cache stability.

Suggested changes

  • Add a bounded, scanner-backed handoff loader next to the existing prompt-context loaders, then test it against a temporary HERMES_HOME.
  • Preserve deterministic file ordering and expose truncation through the existing warning path.

Automated hermes-sweeper review.

Comment thread agent/system_prompt.py
if _sh_dir.is_dir():
_sh_parts = []
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.

Comment thread agent/system_prompt.py
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.

@k-QRedHacker

k-QRedHacker commented Jul 10, 2026 via email

Copy link
Copy Markdown
Author

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 11, 2026
@teknium1 teknium1 added the area/sessions Session lifecycle, resume, persistence, history label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants