Skip to content

fix(agents): resume Hermes panes after a reboot or daemon loss - #31327

Closed
tomaszamoranoq wants to merge 3 commits into
stablyai:mainfrom
tomaszamoranoq:fix/hermes-cold-restore-resume
Closed

tomaszamoranoq wants to merge 3 commits into
stablyai:mainfrom
tomaszamoranoq:fix/hermes-cold-restore-resume

Conversation

@tomaszamoranoq

Copy link
Copy Markdown
Contributor

ELI5

When the Mac reboots, Orca brings back each Claude or Codex pane and reruns claude --resume <id> inside it. Hermes panes come back as an empty shell. Hermes already sends Orca its session id on every hook. Orca discarded it, so it had nothing to resume. This PR keeps the id and resumes with hermes --resume <id>.

What Changed

  • extractAgentProviderSession('hermes', …) now returns { key: 'session_id', id } from the payload of Orca's managed orca-status Hermes plugin. Before, it returned null, next to amp and command-code.
  • Added hermes to RESUMABLE_TUI_AGENTS.
  • getAgentResumeArgv('hermes', …) returns ['hermes', '--resume', id]. Cold restore appends this to the existing launch command, so the default becomes hermes --tui --resume <id>. User command overrides and the recorded launch config still apply.
  • Added the agent-session.hermes-resume.v1 runtime capability and mapped it in agent-resume-host-authority-capability.ts. A newer client checks for it before asking an older remote host to resume a Hermes session. Without that check, the host would return invalid_argument for the new enum member. This follows the same pattern as kiro, kimi and dsh.

Before / after on a real machine. Shape of agent-hooks/last-status.json entries in Orca 1.4.229, values elided:

claude entry: payload.*, agentPresence.*, providerSession.{key,id,transcriptPath}, ...
hermes entry: payload.{agentType,state,prompt,lastAssistantMessage}, agentPresence.agent, ...   <- no providerSession

The plugin sends session_id in every event (SELECTED_KEYS in the managed orca-status/__init__.py), so the id is lost on the Orca side. buildColdRestoreAgentResumeStartup returns early when providerSession is missing.

The session id stays current. When Hermes compresses context it switches to a successor session id (agent.session_id = child_session_id), and the next pre_llm_call reports the new id. Orca therefore resumes the live conversation, not the pre-compression parent.

Why

This is the gap tracked in #15808. Two earlier PRs proposed this: #15809 (@eloklam) and #12075 (@GoodFarming). Both have been inactive for weeks and no longer apply to main. #12075 is marked conflicting, and both fail git apply --check against current main. This PR is the minimal rebase of that approach onto current main. The one addition is the remote-host capability gate, which main now requires for every agent added to RESUMABLE_TUI_AGENTS (an exhaustive Record, so typecheck fails without it). Happy to close this in favour of either earlier PR if the authors refresh them.

Not in scope: Hermes named profiles (#19287). A session from profiles/<name>/state.db resumes correctly only if the pane's recorded launch config or command override still selects that profile. This is the same limitation as Session History resume today.

Linked Issue

Fixes #15808

Visual Proof

N/A. There is no new UI: restored Hermes panes show the same session-restored banner as other resumable agents. The behavior change is the command a cold-restored pane runs, and unit tests cover it.

Testing

  • I manually tested these changes locally (see note below)
  • Automated tests added/updated, or explained why not below

Automated, on macOS (arm64), Node 24:

  • New tests:
    • extraction of the Hermes session_id, which ignores transcript_path
    • Hermes resume argv
    • the hook listener carrying providerSession for Hermes pre_llm_call
    • the cold-restore plan producing hermes --tui '--resume' '<id>'
    • the capability map
  • pnpm test on all 285 test files that reference resumable agents, provider sessions, runtime capabilities or Hermes: 280 passed, 3 skipped, 2 failed. The 2 failing files are src/main/runtime/rpc/methods/agent-launch-replay.test.ts and agent-launch-restart-replay.test.ts (11 tests). They fail the same way on unmodified main (70b2197) and are unrelated to this change.
  • pnpm tc: clean.
  • pnpm run check:code-quality:changed: 0 new findings. oxfmt --check: clean.

Manual: not done yet. I applied the equivalent change to the bundled JS of an installed Orca 1.4.235 on macOS, and I will report back here after a real reboot cycle. Linux, Windows and SSH were not tested manually. The change is in shared code paths those platforms already use for other agents.

AI Disclosure

Prepared with Claude (Anthropic) running inside Hermes Agent, which did the root-cause analysis, the patch and the tests.

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

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 52a9247f-86ed-4647-990c-da2fc479ec3f
📥 Commits

Reviewing files that changed from the base of the PR and between 905ed94 and 3eb580f.

📒 Files selected for processing: 2
  • src/shared/tui-agent-resume-startup.ts
  • src/shared/tui-agent-startup-hermes.spec.ts
🚧 Files skipped from review as they are similar to previous changes: 2
  • src/shared/tui-agent-startup-hermes.spec.ts
  • src/shared/tui-agent-resume-startup.ts

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

📝 Walkthrough

Hermes is included in the resumable-agent allowlist. Its session_id hook value is normalized as a provider session and used to generate resume arguments. Hermes resume support is added to the runtime capability list and host-authority map. Hermes startup commands are normalized for TUI resume. Tests cover session extraction, resume arguments, capability mapping, and startup restore plans.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 3eb58

Unrecognized wrappers do not resume the wrong conversation; the pane falls back to a shell and retains its sleeping record for manual recovery. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 12 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 identifies the primary change: restoring Hermes panes after a reboot or daemon loss.
Description check Passed The description is complete and directly matches the implementation. It explains the user impact, technical changes, rationale, linked issue, testing results, known unrelated failures, and scope limit…
Linked Issues check Passed The PR meets the coding requirements in directly linked issue #15808. extractAgentProviderSession now captures Hermes session_id, and hermes is in RESUMABLE_TUI_AGENTS, which enables persisten…
Out of Scope Changes check Passed The changes stay within #15808. Hermes startup normalization, remote-host capability gating, and the related tests support exact-session cold restore. The PR does not add native Chat UI, live status d…
Full details: Description check

Explanation

The description is complete and directly matches the implementation. It explains the user impact, technical changes, rationale, linked issue, testing results, known unrelated failures, and scope limitations. It also clearly states that manual, Linux, Windows, and SSH testing remains incomplete.

Full details: Linked Issues check

Explanation

The PR meets the coding requirements in directly linked issue #15808. extractAgentProviderSession now captures Hermes session_id, and hermes is in RESUMABLE_TUI_AGENTS, which enables persistence on the sleeping-agent record. getAgentResumeArgv returns ['hermes', '--resume', id]. Cold-restore planning appends this ID to the normalized Hermes TUI command. The changes preserve recorded launch settings and reject unrecognized Hermes wrappers. Tests cover extraction, hook propagation, resume arguments, cold restore, and capability mapping.

Full details: Out of Scope Changes check

Explanation

The changes stay within #15808. Hermes startup normalization, remote-host capability gating, and the related tests support exact-session cold restore. The PR does not add native Chat UI, live status display, Agent Session History scanning, or Hermes named-profile behavior.

  • 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 062837bc-02ca-40b1-8113-1eced22c0dbb
📥 Commits

Reviewing files that changed from the base of the PR and between 4e483ae and bec26ee.

📒 Files selected for processing: 8
  • 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-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

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

Comment thread src/shared/agent-resume-argv.ts Resolved
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.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a73b9d4-2ad0-4767-86bf-c79f2de41d68
📥 Commits

Reviewing files that changed from the base of the PR and between bec26ee and 905ed94.

📒 Files selected for processing: 5
  • src/shared/hermes-startup-query.ts
  • src/shared/tui-agent-resume-startup.ts
  • src/shared/tui-agent-startup-hermes.spec.ts
  • src/shared/tui-agent-startup.spec.ts
  • src/shared/tui-agent-startup.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/shared/tui-agent-startup-hermes.spec.ts

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

Comment thread src/shared/tui-agent-resume-startup.ts Resolved
@nwparker

Copy link
Copy Markdown
Contributor

Thanks for working on Hermes resume! This landed in #33514 (merged, with co-author credit to you), which records the Hermes session id from Orca's plugin hooks, gates remote resume on a new host capability, and keeps delegate children from replacing the pane's session. Closing in favor of it.

nwparker added a commit that referenced this pull request Oct 25, 2026
…ession (#33514)

Hermes panes resume their own conversation after an Orca restart: record the Hermes session id from Orca's Hermes plugin hooks and relaunch with `hermes --resume <id>` (remote hosts gated on agent-session.hermes-resume.v1). Delegate-child hooks no longer replace the pane's session id.

Fixes #15808
Supersedes #31327, #15809, #12075

Co-authored-by: tomaszamoranoq <268064671+tomaszamoranoq@users.noreply.github.com>
Co-authored-by: Yi Lok Enoch Lam <22125285+eloklam@users.noreply.github.com>
Co-authored-by: GoodFarming <34622709+GoodFarming@users.noreply.github.com>
@nwparker nwparker closed this Oct 25, 2026
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