feat(hermes_state): Gateway session activity tracking so silent stalls are visible - #72039
Closed
fangliquanflq wants to merge 8 commits into
Closed
feat(hermes_state): Gateway session activity tracking so silent stalls are visible#72039fangliquanflq wants to merge 8 commits into
fangliquanflq wants to merge 8 commits into
Conversation
Stamp sessions.last_activity_at from AIAgent._touch_activity (rate-limited) so hermes sessions list and hermes status observe API/tool/compaction progress while a gateway turn is still writing no message rows (NousResearch#72016).
Prefer max(last_activity_at, latest message) for session last_active so a rate-limited mid-turn heartbeat cannot rank a session behind newer message timestamps in listings, status, and idle archive.
…t_active Document that last_active is max(heartbeat, message time), and separate the status last-activity test from the preceding class with PEP8 spacing.
Clarify that archive_stale_sessions ages on max(last_activity_at, latest message), matching the shared last_active SQL helper.
13 tasks
Extend the shared session activity observation contract so durable SessionDB heartbeats carry description/provenance alongside the timestamp, matching in-memory get_activity_summary for NousResearch#72039 consumers.
Keep gateway cache turn resets on the ts/desc/provenance triple, and drop the TypeError persist fallback that could silently omit description/provenance.
Keep last_activity_at for idle/watchdog continuity, but wipe description/provenance in memory and SessionDB so idle sessions do not keep advertising the last mid-turn stamp.
fangliquanflq
added a commit
to fangliquanflq/hermes-agent
that referenced
this pull request
Jul 27, 2026
…chdog Use AIAgent.get_activity_summary() / agent.session_activity as the only progress source for pending-inbound stall notify. Drop turn-start and pending-event clocks so NousResearch#72079 stays composable with NousResearch#72039.
…ctivity-tracking Resolved hermes_state.py search_sessions docstring conflict: keep freshest-of last_active semantics from this branch and workspace_key docs from main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds durable mid-turn Gateway session activity tracking so operators can see when a gateway agent turn is still making API/tool/compaction progress, even before new message rows land. This implements suggested feature from #72016 (activity tracking + CLI exposure). It does not add the stall watchdog, compaction timeout, or cumulative stream-retry deadline from that issue.
Motivation
AIAgent already updated an in-memory activity clock on API/tool/compaction work, and the gateway used that for in-process inactivity timeouts. SessionDB
last_activeforhermes sessions list/hermes statuscame only from message timestamps (orstarted_at). During a long or stalled turn with no new messages, CLI surfaces looked idle and gave operators no durable activity signal.How to see the gap
hermes gatewaywith a messaging platform configured.hermes sessions listandhermes status.Desired: listings/status reflect recent agent activity (API/tool/compaction).
Without this feature:
Last Active/ session status stayed frozen on the last message time; status only showed an active session count.What this feature adds
sessions.last_activity_atandSessionDB.touch_session_activity.AIAgent._touch_activity(same cadence posture as the kanban heartbeat bridge).last_activeas freshest of heartbeat and latest message timestamp (so a lagging heartbeat cannot rank behind newer messages).Last activityline inhermes status.Related Issue
Related to #72016 (implements suggested item #1: Gateway session activity tracking). Does not close the issue; stall watchdog / compaction timeout / cumulative retry deadline remain open.
Type of Change
Changes Made
hermes_state.py-last_activity_atcolumn, touch helper, freshest-oflast_activeSQL for list/status/archive pathsrun_agent.py/agent/agent_init.py- rate-limited durable persist from_touch_activityhermes_cli/status.py- print freshest gateway last activitytests/run_agent/test_session_activity_persist.py,tests/test_hermes_state.py,tests/hermes_cli/test_status.py- coverage for persist cadence, freshest-of ranking, status lineHow to Test
hermes sessions listadvances Last Active from heartbeats andhermes statusshowsLast activity.Checklist
Code
scripts/run_tests.shon relevant tests and they passDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys - N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows - N/A