Skip to content

fix(agents): resume Hermes panes after a restart, on the pane's own session - #33514

Merged
nwparker merged 3 commits into
mainfrom
nwparker/agint-hermes-tui-resume
Oct 25, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/agint-hermes-tui-resume

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​71 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​66
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62

Summary

If Orca restarted after a crash, reboot, or daemon loss, a Hermes TUI pane came back as a plain shell, and the conversation was gone. Claude, Codex, Kiro and other agents already resume in this case. Hermes now does too: Orca stores the Hermes session id from its managed plugin and relaunches the pane with hermes --tui --resume <id>.

This adopts @tomaszamoranoq's #31327 (both of its main commits are kept) and adds one commit:

  1. Delegate children no longer take over the pane's session. Hermes delegate_task children send hooks to the parent's pane under their own session ids. Taking every hook's session_id as-is (as fix(agents): resume Hermes panes after a reboot or daemon loss #31327 did) let a restore reopen the child conversation. It also wiped the pane's resume record, so the restore lost the launch args (--yolo, profile flags). Child hooks now carry the parent's id. A child is detected the same way fix(hermes): keep a finished Hermes pane done when its background memory review calls tools #33418 detects one: platform: "subagent", or a session id already seen as a child in this turn.
  2. Dropped the Hermes-only resume command rewrite (normalizeHermesResumeBaseCommand plus the wrapper refusal). Top-level hermes --tui --resume <id> works, so Hermes now uses the same plain-append path as every other agent. That is about 30 fewer lines.

Fixes #15808

Root cause

  • extractAgentProviderSession returned null for hermes, and hermes was not in RESUMABLE_TUI_AGENTS. No provider session was ever recorded, so cold restore had nothing to resume.
  • A prompted Hermes launch passes agentArgs inside its --query command, so the recorded agentCommand was missing them and a resume would have dropped them. fix(agents): resume Hermes panes after a reboot or daemon loss #31327 commit 2 records the full command.

Upstream Hermes (~/projects/hermes-agent):

  • hermes_cli/_parser.py:175 defines top-level --resume/-r SESSION, and :208 defines --tui. hermes_cli/main.py:1356-1378 (_resolve_session_by_name_or_id) resolves an exact id and moves forward to the compression tip, so an id recorded before context compression still resumes the live conversation.
  • tools/delegate_tool.py:296 runs children with platform="subagent". Children use their own session ids (see the captured hook order in fix(hermes): keep a finished Hermes pane done when its background memory review calls tools #33418).

Mixed versions / remote / mobile

  • Remote hosts are gated behind the new agent-session.hermes-resume.v1 runtime capability, like the other agents added late (from fix(agents): resume Hermes panes after a reboot or daemon loss #31327). An older host never receives a hermes resume it would reject.
  • Folder workspaces: verified on a folder project. Nothing here depends on git.
  • Mobile: no UI change. Restore runs in the desktop/runtime.

Verification

Real app, real hermes CLI v0.13.0. Isolated HOME/HERMES_HOME, Orca dev profile, and a local fake OpenAI-compatible model, so no model spend. Steps: launch a Hermes pane from the tab "+" menu, send "remember the word zebra42", then hard-kill Orca, its PTY daemon and the pane processes (same as a reboot), and relaunch.

after restart
main (751591f) pane comes back as a bare shell. The status entry had providerSession: null
this PR daemon runs hermes --tui --yolo --resume 20261025_041233_b88cf8, the pane shows the earlier turn, and the next prompt reaches the model with both user messages (history=2)

Before (main):

main after restart

After (this PR):

PR after restart

  • Delegate run (delegateit → delegate_task child): the pane's provider session stays on the parent id (the child is parent_session_id = parent in state.db), and the restore resumes the parent conversation.
  • pnpm tc, plus targeted suites: listener, session resume, startup, host-authority capability, hermes, agent-status slices and terminal-pane (646 files, 7432 tests). check:code-quality:changed passes.
  • New regression test: the real delegate_task hook order keeps the pane on the parent id. It fails without the fix.

Risk

Co-authored-by: tomaszamoranoq tomas.zamorano@uc.cl

tomaszamoranoq and others added 3 commits October 25, 2026 04:10
Orca's managed Hermes plugin already posts session_id on every hook, but
extractAgentProviderSession dropped it for hermes, so the pane never stored a
provider session and cold restore had nothing to resume. Capture the id, add
hermes to RESUMABLE_TUI_AGENTS, map it to `hermes --resume <id>`, and gate
remote hosts behind agent-session.hermes-resume.v1 like the other late agents.
A prompted Hermes launch splices agentArgs into its query command, so the
recorded agentCommand lacked them and resume replayed the bare override. Record
the full command like every other agent, and normalize the resumed command into
TUI chat form so a --cli override or a stale --query never survives a restore.
…ate child's

delegate_task children post hooks under their own session ids on the parent's
pane; those now carry the parent's id, so a restore never reopens a child and
the pane's resume record keeps its launch args. Resume reuses the plain append
path every other agent uses (top-level `hermes --tui --resume <id>` works), so
the Hermes-specific resume command rewrite is dropped.

Co-authored-by: tomaszamoranoq <tomas.zamorano@uc.cl>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Hermes is added to the resumable-agent list and runtime capability mappings. Hook processing uses the pane’s Hermes session ID when resolving events from subagents or child sessions. Resume argument generation uses that session ID, and Hermes startup plans retain launch options when building a resume command.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to eccf9

Hermes panes should now resume on their own session after a restart. A narrow edge case remains: unusual prompted-launch flags such as --query could be replayed when a pane resumes. This is worth a quick check but is unlikely to affect normal use.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the primary change: resuming Hermes panes after a restart while preserving the pane's own session.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, linked issue, visual proof, testing, compatibility considerations, and known risks. It uses alternate headings instea…
Linked Issues check Passed Issue #15808 requires exact Hermes hook-session capture, persistence on the sleeping-agent record, and cold restore with hermes --tui --resume <session_id>. The PR adds hermes to `RESUMABLE_TUI_AG…
Out of Scope Changes check Passed The changed areas remain connected to Issue #15808. Runtime capability gating supports safe remote and mixed-version restore. Hermes child-hook handling prevents a delegated child from replacing the p…
Full details: Description check

Explanation

The description is detailed and covers the user impact, implementation, rationale, linked issue, visual proof, testing, compatibility considerations, and known risks. It uses alternate headings instead of the full template and does not include the checklist or explicit AI Disclosure and Agent skill upstream boundary sections, but the required information is mostly present.

Full details: Linked Issues check

Explanation

Issue #15808 requires exact Hermes hook-session capture, persistence on the sleeping-agent record, and cold restore with hermes --tui --resume &lt;session_id&gt;. The PR adds hermes to RESUMABLE_TUI_AGENTS, extracts session_id, and maps it to ['hermes', '--resume', id]. The startup changes preserve prompted agentArgs in the recorded launch configuration. The supplied regression tests cover Hermes extraction, resume arguments, startup configuration, and parent-session retention for delegate-child hooks. The PR evidence also reports a real crash-restore test that resumed the prior conversation.

Full details: Out of Scope Changes check

Explanation

The changed areas remain connected to Issue #15808. Runtime capability gating supports safe remote and mixed-version restore. Hermes child-hook handling prevents a delegated child from replacing the pane's session. Prompted-launch and startup tests protect the exact restore command and its arguments. The listed production changes and tests do not demonstrate unrelated functionality.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

🔇 Additional comments: 2
src/shared/agent-hook-listener/providers/hermes-events.ts-63-64: 1

63-64: Major · Data Integrity & Integration · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Record child IDs at session start.

If a delegate emits on_session_start and then on_session_end before pre_llm_call, this check does not recognize the child. The end hook can omit platform, as the new regression sequence shows. readPaneProviderSession then publishes the child’s ID as the pane’s provider session, so a crash restore can select the wrong conversation. Add the child ID to childSessionIds when its marked on_session_start arrives.

src/shared/tui-agent-startup.ts-89-91: 1

89-91: Major · Functional Correctness · Heavy lift

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Record the effective Hermes command, not discarded flags.

When a prompted launch supplies hermes --query override --cli, the query launch removes those flags, but recordedCommand.commandWithoutSessionOptions retains them. A later resume appends --resume <id> to that recorded command. It can therefore replay the old query or start the classic REPL instead of restoring the intended TUI. Store the Hermes query planner’s effective launch options without its startup query, rather than persisting the unprocessed override and arguments. Hermes documents --cli as the classic-REPL switch and --query as a query input. (github.com)


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bb0faa01-a746-48e8-96e5-2cb41662260d
Commits

Reviewing files that changed from the base of the PR and between 7d6603a and eccf9cb.

Files selected for processing: 14
  • src/renderer/src/runtime/agent-resume-host-authority-capability.test.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.ts
  • src/shared/agent-hook-listener-hermes-codex-droid.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-listener/listener-state.ts
  • src/shared/agent-hook-listener/pane-provider-session.ts
  • src/shared/agent-hook-listener/providers/hermes-events.ts
  • src/shared/agent-resume-argv.ts
  • src/shared/agent-session-resume-runtime-capabilities.ts
  • src/shared/agent-session-resume.test.ts
  • src/shared/agent-session-resume.ts
  • src/shared/tui-agent-startup-hermes.spec.ts
  • src/shared/tui-agent-startup.spec.ts
  • src/shared/tui-agent-startup.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Resume Hermes TUI sessions after crash or quit

2 participants