hermes - 💡(How to fix) Fix [Feature]: session:pre_reset hook — auto-summary on /new with 10s opt-out [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#13556Fetched 2026-04-22 08:05:52
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Error Message

Workaround today: users manually copy/paste a summary into the first message of the new session. This is manual, error-prone, and not persisted.

Root Cause

  1. Hook-based workaround — A skill using existing session:end/session:reset hooks. Rejected because: (a) hook return values are discarded in hooks.py:165, (b) hooks fire after reset_session() so nothing can inject into the new session, (c) no channel exists to carry summary data to the next session. 2. Always auto-summary, no opt-out — Rejected because users who intentionally use /new for a truly clean slate would always get unwanted context prepended. 3. Config flag only, no hooks — Rejected because some users want custom summarization logic (e.g., different formats per conversation type), and a hook provides that extensibility. 4. Skill-generated summary injected manually — Users could run a skill to summarize before /new, then paste. Rejected because it's manual, not persisted, and requires the user to remember to do it.

Fix Action

Fix / Workaround

Workaround today: users manually copy/paste a summary into the first message of the new session. This is manual, error-prone, and not persisted.

  1. Hook-based workaround — A skill using existing session:end/session:reset hooks. Rejected because: (a) hook return values are discarded in hooks.py:165, (b) hooks fire after reset_session() so nothing can inject into the new session, (c) no channel exists to carry summary data to the next session. 2. Always auto-summary, no opt-out — Rejected because users who intentionally use /new for a truly clean slate would always get unwanted context prepended. 3. Config flag only, no hooks — Rejected because some users want custom summarization logic (e.g., different formats per conversation type), and a hook provides that extensibility. 4. Skill-generated summary injected manually — Users could run a skill to summarize before /new, then paste. Rejected because it's manual, not persisted, and requires the user to remember to do it.

Code Example

/new → emit "session:pre_reset" → handler returns summary
      → send confirmation prompt with 10s timeout
      → user: default → summary prepended to new session
      → user: cancel  → pure reset (old behavior)
      → user: "/"     → pure reset (old behavior)

---
RAW_BUFFERClick to expand / collapse

Problem or Use Case

When a user types /new to start a fresh conversation, the session resets completely — no history, no context from the prior conversation is retained. This is often the desired behavior, but there are cases where the user wants to "pick up where they left off" in a new session without losing what was discussed.

Workaround today: users manually copy/paste a summary into the first message of the new session. This is manual, error-prone, and not persisted.

Proposed Solution

Add a session:pre_reset hook event that fires before the session is reset. Handlers can: 1. Access the full conversation transcript via load_transcript(session_id) 2. Generate a summary 3. Return {"summary": "..."} — the return value is captured and stored in the new SessionEntry as a prepend_summary field 4. The next agent message prepends this summary to the system prompt

**User-facing behavior:**
- User types `/new`
- Agent generates a summary of the current session (~200-400 tokens, fast)
- Agent sends: *"✨ Session reset — summary prepended to new chat. [Cancel to skip]"*
- **10-second window**: user can type `cancel` or `/` to opt out
- **Default (no input)**: new session starts with summary prepended 
- **If cancel**: pure reset, no summary (old behavior)
 
**Config option:** `prepend_summary_on_reset: bool` (default: `true`) — users who always want pure resets can disable it. When disabled, the 10s prompt is skipped entirely.
 
**Scope:** This is purely additive — no breaking changes, no deletion of existing behavior.
 
Flow:
```
/new → emit "session:pre_reset" → handler returns summary
  → send confirmation prompt with 10s timeout
  → user: default → summary prepended to new session
  → user: cancel  → pure reset (old behavior)
  → user: "/"     → pure reset (old behavior)
```
 
Files to modify (~200 lines, all additions):
- `gateway/hooks.py` — add `session:pre_reset` event
- `gateway/run.py` — capture hook return, implement timeout/cancel logic
- `gateway/session.py` — add `prepend_summary` field to `SessionEntry`
- `agent/prompt_builder.py` — inject summary into system prompt
- `cli-config.yaml.example` — add `prepend_summary_on_reset` config key

Alternatives Considered

1. **Hook-based workaround** — A skill using existing `session:end`/`session:reset` hooks. Rejected because: (a) hook return values are discarded in `hooks.py:165`, (b) hooks fire *after* `reset_session()` so nothing can inject into the new session, (c) no channel exists to carry summary data to the next session.
2. **Always auto-summary, no opt-out** — Rejected because users who intentionally use `/new` for a truly clean slate would always get unwanted context prepended.
3. **Config flag only, no hooks** — Rejected because some users want custom summarization logic (e.g., different formats per conversation type), and a hook provides that extensibility.
4. **Skill-generated summary injected manually** — Users could run a skill to summarize before `/new`, then paste. Rejected because it's manual, not persisted, and requires the user to remember to do it.

Feature Type

Performance / reliability

Scope

Medium (few files, < 300 lines)

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

extent analysis

TL;DR

To fix the issue of losing conversation history when a user types /new, implement a session:pre_reset hook event that allows handlers to generate and prepend a summary to the new session.

Guidance

  • Modify the gateway/hooks.py file to add the session:pre_reset event, which will fire before the session is reset.
  • Update the gateway/run.py file to capture the hook return value and implement the 10-second timeout and cancel logic.
  • Add a prepend_summary field to the SessionEntry in gateway/session.py to store the generated summary.
  • Inject the summary into the system prompt in agent/prompt_builder.py.

Example

# gateway/hooks.py
def session_pre_reset(session_id):
    # Load conversation transcript and generate summary
    transcript = load_transcript(session_id)
    summary = generate_summary(transcript)
    return {"summary": summary}

# gateway/run.py
def handle_new_session(session_id):
    # Emit session:pre_reset event and capture return value
    summary = emit("session:pre_reset", session_id)
    # Send confirmation prompt with 10s timeout
    send_prompt("Session reset — summary prepended to new chat. [Cancel to skip]", 10)
    # Handle user input (cancel or default)
    user_input = get_user_input()
    if user_input == "cancel":
        # Pure reset, no summary
        reset_session(session_id)
    else:
        # Prepend summary to new session
        prepend_summary_to_session(session_id, summary)

Notes

The proposed solution requires modifying several files, including gateway/hooks.py, gateway/run.py, gateway/session.py, and agent/prompt_builder.py. The changes are additive, and the prepend_summary_on_reset config option allows users to disable the feature if desired.

Recommendation

Apply the proposed workaround by implementing the session:pre_reset hook event and modifying the necessary files. This solution provides a flexible and extensible way to generate and prepend summaries to new sessions, while also allowing users to opt out if desired.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Feature]: session:pre_reset hook — auto-summary on /new with 10s opt-out [1 participants]