Feat/cron session titles - #39363
Closed
anthonyarmijo wants to merge 2 commits into
Closed
Conversation
Cron sessions currently appear as 'cron_<id>_<timestamp>' with no title in 'hermes sessions list', making them indistinguishable. After a cron job completes (success or failure), set the session title to the job's name via set_session_title(). This makes cron sessions immediately identifiable in session listings. The title is set in a try/except block so a title collision or DB issue never blocks the cron job from completing.
Set session title to the job name after each cron run, so sessions are identifiable in 'hermes sessions list' instead of showing the raw 'cron_<id>_<timestamp>' ID. Moved title-setting to the finally block so it fires on both success and failure paths without code duplication. Catches ValueError specifically (title collision) and logs a warning instead of silently swallowing all exceptions. Added three tests: - set_session_title called on agent failure - ValueError from set_session_title does not crash the job - _session_db is None handled gracefully
Contributor
|
Thanks for the focused cron-session usability improvement. This is an automated hermes-sweeper review; current
|
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?
Cron sessions currently appear as
cron_<id>_<timestamp>with no title inhermes sessions list, making them indistinguishable from each other. Whenyou have 10+ cron jobs, there's no way to tell which session was which
without cross-referencing job IDs.
This sets the session title to the cron job's name after each run via
set_session_title(), so sessions are immediately identifiable.Why
finallyblock?The call fires on both success and failure without
code duplication. It sits right before
end_session()— same guard(
if _session_db:), same lifetime.Why catch only
ValueError?set_session_title()raisesValueErroron title collision or invalid length. We log a warning and let the job
complete — a title collision shouldn't block cron execution. All other
exceptions propagate (the
finallyblock's existingend_session/closecalls also catch broadly, so this is consistent).Why no new schema field?
Job names already serve as descriptive
identifiers (they cap at 50 chars, well under the 100-char title limit).
No new config, no migration, no API changes.
Note on existing PRs
PRs #14813 and #23121 propose similar features with different approaches. This PR is the minimal implementation:
hermes_state.pyandrun_agent.pyto passthe title at session creation time, which required a follow-up fix for
uniqueness collisions on repeated runs (lineage titles:
#2,#3). This PRavoids that entirely by using the existing
set_session_title()API in thefinallyblock — the session already has a unique ID, so collisions arehandled gracefully via
ValueError.title_generator.pyrewrite(two features, one PR), adds opinionated date suffixes (
· 2026-05-10), andinjects token-tracking imports. This PR is a single focused change — 9 lines
in the scheduler, cron-only, no opinionated formatting.
Related Issue
N/A — small self-contained improvement.
Type of Change
Changes Made
cron/scheduler.py— addedset_session_title()call infinallyblock (line ~1940), after TERMINAL_CWD/ContextVar cleanup and beforeend_session(). CatchesValueErrorwithlogger.warning().tests/cron/test_scheduler.pyset_session_titleassertions to existing success-path testtest_run_job_sets_session_title_on_failure— agent raises →title still set
test_run_job_handles_session_title_valueerror— collisiondoesn't crash the job
test_run_job_skips_title_when_session_db_is_none— noSessionDB → no crash
How to Test
—_session_dbisNone:Checklist
Code
pytest tests/cron/— 495 passedDocumentation & Housekeeping
cli-config.yaml.example— N/A (no config keys added)CONTRIBUTING.md/AGENTS.md— N/A (no architecture changes)Screenshots / Logs
Before — all cron sessions show
—with no title:After — the session title is the job's name:
The still-untitled session (
cron_a421*) ran before the gateway wasrestarted with the new code — all subsequent runs get titled automatically.