Fix Hermes restore after turn end#5020
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughDistinguishes per-turn agent hooks from true session boundaries by centralizing hook-name extraction and adding a predicate that treats hermes-agent on_session_end as a turn boundary; updates session-end handling and adds an integration test verifying restore-route preservation and finalization cleanup. ChangesHermes session restore via turn-boundary detection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 17 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (17 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR fixes a bug where Hermes's per-turn
Confidence Score: 5/5Safe to merge. The change is narrowly scoped to the hermes-agent session-end branch and is guarded by a new integration test that exercises all three lifecycle events. The new No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[".sessionEnd case"] --> B{def.name == codex?}
B -- yes --> C[retireCodexMonitorLeases]
C --> D{sessionEndIsTurnBoundary?}
B -- no --> D
D -- yes --> E[sendAgentFeedTelemetry\nrecordPromptStop\nbreak — keep restore route]
D -- no --> F{store.lookup found?}
F -- yes --> G{suppressVisibleMutations?}
G -- yes --> H[breadcrumb only]
G -- no --> I[store.consume\nclearAgentSurfaceResumeBinding\nclear_agent_pid]
F -- no --> J[no-op]
subgraph sessionEndIsTurnBoundary
K{grok or antigravity?} -- yes --> L[return true]
K -- no --> M{hermes-agent?}
M -- no --> N[return false]
M -- yes --> O{event == on_session_end?}
O -- yes --> P[return true]
O -- no --> Q[return false]
end
Reviews (2): Last reviewed commit: "fix: share hermes hook event lookup" | Re-trigger Greptile |
Fixes #5000
Summary:
on_session_endas a turn boundary, matching how Hermes emits it after every response.on_session_end.on_session_finalizeas the destructive session boundary that clears the restore binding and agent pid.Red failure:
7e8c94b08686a11af8ebd15077a4f58f256a4634/Users/lawrence/fun/cmuxterm-hq/cmux-assets/issue-5000-hermes-auto-restore/auto-issue/20260530-032134/before-window/recording.mov| TLDR: redcmuxconsumes the Hermes route on per-turnon_session_end, printsstored_after_on_session_end=[], and sendssurface.resume.clearplusclear_agent_pid.Green verification:
a708ba41e37b8b819f2466af4e211d4e951d1ac6,956a492e07d0fcf38ca991e7ca4f58a48f95be31./scripts/reload.sh --tag hrestpassed after the Greptile cleanup./Users/lawrence/fun/cmuxterm-hq/cmux-assets/issue-5000-hermes-auto-restore/auto-issue/20260530-032134/hermes-fixed2-output.txtconfirms the final PR head keeps the route afteron_session_endand clears onon_session_finalize./Users/lawrence/fun/cmuxterm-hq/cmux-assets/issue-5000-hermes-auto-restore/auto-issue/20260530-032134/after-window/recording.mov| TLDR: fixedcmuxkeepshermes-session-restoreafteron_session_end, sends onlyfeed.push, then clears onon_session_finalize.Proof notes:
cloud-mac-26681540992, macOS 26.5)before-window/frames/02.png,before-window/frames/tail.png,after-window/frames/02.png, andafter-window/frames/tail.png.