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:
- compression count reaches
after_compressions;
- preflight prompt tokens exceed
max_prompt_tokens or a model-derived threshold;
- compression summary generation fails and Hermes inserts a fallback/lossy marker;
- repeated compression cooldowns or timeouts happen;
- 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
Related issues
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.
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:
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:
end_reason='compression'continuation chains;/new//resetsession controls;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:
Trigger examples
Hermes could offer a handoff when any configured threshold is met:
after_compressions;max_prompt_tokensor a model-derived threshold;/handoffor/fresh.Handoff packet
The outgoing session should produce a structured, compact packet that a fresh agent can trust and verify:
Prefer saving this packet as an artifact, for example:
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
Session compressed 2 times; creating fresh handoff...Continue in fresh session? [Y/n].Gateway / messaging
ACP / VS Code
ACP is the most important case for this request.
Minimum viable behavior:
Continue in fresh sessionaction.Ideal behavior:
Safety / autonomy rules
The feature should not blindly continue through risky boundaries.
Suggested defaults:
mode: prompt_userorfresh_sessiononly after a safe checkpoint;require_clean_checkpoint: true;.envvalues, raw credentials, or private health/payment data in the handoff packet;Acceptance criteria
agent.auto_handoff_on_compression./handoffor similar) can produce a handoff packet without starting a new session.handofforcompression_handoff.parent_session_idor equivalent relationship.Related issues
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.