hermes - 💡(How to fix) Fix Feature: automatic fresh-session handoff when compression becomes risky [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#20372Fetched 2026-05-06 06:37:04
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Error Message

A concrete related bug was filed as #20250, where a VS Code ACP prompt remained in-flight after repeated compression timeout. That issue is about fixing the stall/error path. This feature request is about a proactive lifecycle policy: before repeated compression becomes dangerous, hand off to a fresh agent/session.

Root Cause

  • #20250 — bug: VS Code ACP prompt can remain in-flight after repeated compression timeout. This feature would reduce the likelihood of reaching that state, but does not replace the need to fix the stall path.
  • #15618 — exposing context/compression metadata in API run events would make this easier for clients to display.
  • #8366 — cross-platform session handoff. This request is narrower/different: automatic lifecycle handoff to a fresh context because compression has become risky.
  • #499 — context compaction quality / handoff-oriented prompts. This request is not just a better compaction prompt; it asks for a first-class fresh-session/agent lifecycle transition.

Code Example

agent:
  auto_handoff_on_compression:
    enabled: false
    after_compressions: 2
    max_prompt_tokens: null          # optional absolute token trigger
    on_compression_failure: true     # trigger after fallback/timeout/lossy marker
    mode: fresh_session              # fresh_session | fresh_process | prompt_user
    handoff_artifact_dir: .hermes/handoffs
    max_auto_handoffs: 3
    require_clean_checkpoint: true
    prompt: |
      Create a compact handoff packet for a fresh Hermes session. Include repo path,
      branch, git status, active plan/artifact paths, completed work, validation already
      run, blockers, and exact next task. Do not include secrets or raw credentials.

---

# Hermes handoff packet

## Scope
- Workspace/repo path:
- Current branch:
- Current task/request:
- Active profile/model/toolsets:

## Current repo state
- `git status --short` summary:
- Staged/unstaged files:
- Latest relevant commits:

## Completed work
- ...

## Validation already run
- command:
- result:
- evidence path/log path:

## Open blockers / approvals needed
- ...

## Next recommended action
- exact next command or task:

## Safety notes
- do not repeat:
- do not modify without approval:
- secrets intentionally omitted:

---

.hermes/handoffs/<session-id>-<timestamp>.md
RAW_BUFFERClick to expand / collapse

Feature request

Add a first-class automatic fresh-session handoff mode for long-running Hermes tasks when context compression becomes risky or repeatedly degrades.

The goal is to avoid the failure mode where a useful, multi-hour agent session keeps compressing in-place until it becomes slow, inaccurate, or prone to ACP/gateway stalls. Instead, Hermes should be able to create a compact handoff packet, end the risky session cleanly, and continue in a fresh session/agent with a small, task-focused context.

Motivation

In long VS Code ACP / coding sessions, compression can keep the conversation alive, but after several compressions the session becomes fragile:

  • context summaries can become lossy;
  • completed tasks can remain overrepresented;
  • current task focus can drift;
  • preflight/auxiliary compression can be slow or timeout;
  • ACP clients can appear stuck while the backend is still trying to compress or recover.

A concrete related bug was filed as #20250, where a VS Code ACP prompt remained in-flight after repeated compression timeout. That issue is about fixing the stall/error path. This feature request is about a proactive lifecycle policy: before repeated compression becomes dangerous, hand off to a fresh agent/session.

Hermes already has useful building blocks:

  • context compression;
  • session DB parent/child links and end_reason='compression' continuation chains;
  • /new / /reset session controls;
  • session search and persisted transcripts;
  • subagent/fresh process capabilities.

But today those pieces do not provide a product-level fresh-agent handoff. The live runtime generally continues with compressed context rather than producing a clean handoff artifact and starting a fresh context.

Proposed behavior

Add configurable policy, for example:

agent:
  auto_handoff_on_compression:
    enabled: false
    after_compressions: 2
    max_prompt_tokens: null          # optional absolute token trigger
    on_compression_failure: true     # trigger after fallback/timeout/lossy marker
    mode: fresh_session              # fresh_session | fresh_process | prompt_user
    handoff_artifact_dir: .hermes/handoffs
    max_auto_handoffs: 3
    require_clean_checkpoint: true
    prompt: |
      Create a compact handoff packet for a fresh Hermes session. Include repo path,
      branch, git status, active plan/artifact paths, completed work, validation already
      run, blockers, and exact next task. Do not include secrets or raw credentials.

Trigger examples

Hermes could offer a handoff when any configured threshold is met:

  1. compression count reaches after_compressions;
  2. preflight prompt tokens exceed max_prompt_tokens or a model-derived threshold;
  3. compression summary generation fails and Hermes inserts a fallback/lossy marker;
  4. repeated compression cooldowns or timeouts happen;
  5. the user explicitly runs a command such as /handoff or /fresh.

Handoff packet

The outgoing session should produce a structured, compact packet that a fresh agent can trust and verify:

# Hermes handoff packet

## Scope
- Workspace/repo path:
- Current branch:
- Current task/request:
- Active profile/model/toolsets:

## Current repo state
- `git status --short` summary:
- Staged/unstaged files:
- Latest relevant commits:

## Completed work
- ...

## Validation already run
- command:
- result:
- evidence path/log path:

## Open blockers / approvals needed
- ...

## Next recommended action
- exact next command or task:

## Safety notes
- do not repeat:
- do not modify without approval:
- secrets intentionally omitted:

Prefer saving this packet as an artifact, for example:

.hermes/handoffs/<session-id>-<timestamp>.md

The packet should avoid secrets, avoid dumping huge raw tool output, and prefer references to files/logs/artifacts that the fresh agent can inspect.

Platform UX

CLI / TUI

  • Show a clear message: Session compressed 2 times; creating fresh handoff...
  • Start a new session automatically when configured, or ask: Continue in fresh session? [Y/n].
  • New session starts with the handoff packet plus an instruction to verify live repo state before editing.

Gateway / messaging

  • For unattended/high-autonomy sessions, auto-handoff can continue in a new logical session and post a short notice with the handoff path.
  • For lower-autonomy settings, send the handoff packet and ask the user to confirm continuation.

ACP / VS Code

ACP is the most important case for this request.

Minimum viable behavior:

  • Old ACP turn completes cleanly with a visible handoff message and artifact path.
  • Hermes emits enough metadata/event information for clients to present a Continue in fresh session action.
  • If client-side auto-switch is not available, the final message should be copy/paste-ready for a new chat.

Ideal behavior:

  • Hermes starts a fresh ACP session, linked to the prior session, and the VS Code extension switches or offers a one-click switch to it.

Safety / autonomy rules

The feature should not blindly continue through risky boundaries.

Suggested defaults:

  • disabled by default initially;
  • mode: prompt_user or fresh_session only after a safe checkpoint;
  • stop and ask if destructive/external side effects are next;
  • require clean git status or a checkpoint commit when require_clean_checkpoint: true;
  • never include secrets, tokens, .env values, raw credentials, or private health/payment data in the handoff packet;
  • preserve links to original session/transcript for auditability.

Acceptance criteria

  • Config schema and defaults exist for agent.auto_handoff_on_compression.
  • Hermes tracks compression count / lossy compression failures in a way the policy can use.
  • A manual command (/handoff or similar) can produce a handoff packet without starting a new session.
  • Automatic policy can trigger after N compressions or compression failure.
  • Old session is finalized cleanly with a distinct end reason such as handoff or compression_handoff.
  • New session is linked to the old one via parent_session_id or equivalent relationship.
  • Fresh session starts with the handoff packet and verifies live repo state before editing.
  • ACP/gateway clients receive a clear final/transition message rather than a dangling in-flight prompt.
  • Tests cover CLI/TUI, gateway/API, and ACP lifecycle behavior.

Related issues

  • #20250 — bug: VS Code ACP prompt can remain in-flight after repeated compression timeout. This feature would reduce the likelihood of reaching that state, but does not replace the need to fix the stall path.
  • #15618 — exposing context/compression metadata in API run events would make this easier for clients to display.
  • #8366 — cross-platform session handoff. This request is narrower/different: automatic lifecycle handoff to a fresh context because compression has become risky.
  • #499 — context compaction quality / handoff-oriented prompts. This request is not just a better compaction prompt; it asks for a first-class fresh-session/agent lifecycle transition.

Why this should be first-class

Users can manually ask for a handoff today, but manual handoffs happen too late: the user notices the session is stale only after it has already become degraded or stuck. Hermes has enough internal signals to detect the danger earlier and either offer or perform a clean transition.

A proactive handoff policy would make long-running coding and operations sessions more reliable than repeatedly compressing the same live session until it fails.

extent analysis

TL;DR

Implement a configurable policy for automatic fresh-session handoff in Hermes when context compression becomes risky or repeatedly degrades.

Guidance

  • Review the proposed agent.auto_handoff_on_compression configuration schema and defaults to understand the available settings and thresholds for triggering a handoff.
  • Consider the different trigger examples, such as compression count, preflight prompt tokens, and compression failure, to determine the best approach for your use case.
  • Develop a structured and compact handoff packet that includes relevant information, such as workspace/repo path, current branch, and completed work, while avoiding secrets and raw credentials.
  • Implement tests to cover various scenarios, including CLI/TUI, gateway/API, and ACP lifecycle behavior, to ensure the handoff feature works as expected.

Example

agent:
  auto_handoff_on_compression:
    enabled: true
    after_compressions: 3
    max_prompt_tokens: 1000
    on_compression_failure: true
    mode: fresh_session
    handoff_artifact_dir: .hermes/handoffs

Notes

The implementation of the handoff feature should prioritize safety and autonomy rules, such as requiring a clean git status or checkpoint commit, and preserving links to original sessions for auditability.

Recommendation

Apply the proposed agent.auto_handoff_on_compression policy to enable automatic fresh-session handoff, as it provides a proactive approach to managing long-running sessions and reducing the likelihood of compression-related issues.

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: automatic fresh-session handoff when compression becomes risky [1 participants]