feat: session handoff — auto-load continuity files between sessions - #61840
feat: session handoff — auto-load continuity files between sessions#61840k-QRedHacker wants to merge 1 commit into
Conversation
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 (量子红客组织)
teknium1
left a comment
There was a problem hiding this comment.
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:484bypasses_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
*.mdfile with no per-file or aggregate cap, unlike existing context sources, whose cap is defined inagent/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.
| if _sh_dir.is_dir(): | ||
| _sh_parts = [] | ||
| for _sh_f in sorted(_sh_dir.glob("*.md")): | ||
| if _sh_f.is_file(): |
There was a problem hiding this comment.
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.
| from hermes_constants import get_hermes_home as _SHget_hh | ||
| _sh_dir = _SHPath(_SHget_hh()) / "session_handoff" | ||
| if _sh_dir.is_dir(): | ||
| _sh_parts = [] |
There was a problem hiding this comment.
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.
|
来件已收悉,谢谢。
|
Session Handoff: Auto-Load Continuity Files Between Sessions
This PR adds a lightweight session handoff mechanism to Hermes Agent. Users can place
*.mdfiles 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
~/.hermes/session_handoff/for all*.mdfiles at session build timevolatile_parts(same tier as memory and user profile)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
agent/system_prompt.pybuild_system_prompt_parts()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).