feat(cron): pass job name as session title for cron sessions - #14813
feat(cron): pass job name as session title for cron sessions#14813waldmanz wants to merge 2 commits into
Conversation
Cron job sessions previously had no title in the SQLite session store, causing the web UI to display truncated system prompt text as session titles (e.g., '[SYSTEM: You are running as a scheduled cron job...]'). Pass the job's human-readable name through to SessionDB.create_session() so cron sessions display meaningful titles like 'wiki-auto-ingest', 'Hermes Tips', etc. in the sessions list, dashboard, and session search. Changes: - hermes_state.py: Add optional 'title' parameter to create_session() - run_agent.py: Accept 'session_title' in AIAgent.__init__ and forward it - cron/scheduler.py: Pass session_title=job_name when constructing AIAgent All parameters are optional with defaults that preserve existing behavior. No migration needed — the title column already exists in the schema.
|
Thanks — I pushed a follow-up fix for the session-title behavior. What changed
Why this follow-up was needed This follow-up fixes that by allocating a unique sanitized title before insert, and by threading the title through the ensure_session() recovery path too. Tests added
Validation
Pushed in:
|
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing the cron-session naming gap. Current main already titles sessions in the scheduler finalizer, but the repeated-run edge case remains.
Problems
cron/scheduler.py:3297formats the suffix only through minutes. Two same-name runs completing in one minute generate the same title;hermes_state.py:2743-2745raisesValueError, andcron/scheduler.py:3299-3300logs and suppresses it, leaving the later session untitled.- The PR targets an older persistence shape. Current session creation is centralized by
hermes_state.py:1610-1668and invoked byrun_agent.py:598-607, so the creation-time plumbing needs adaptation rather than a direct cherry-pick.
Suggested changes
- Keep the current finalizer path and allocate a numbered fallback with
SessionDB.get_next_title_in_lineage()(hermes_state.py:2852-2885) beforeset_session_title(). - Add a fixed-clock regression covering two same-name runs in one minute and assert both sessions retain distinct titles.
This is an automated hermes-sweeper review.
| @@ -643,6 +648,48 @@ def sanitize_title(title: Optional[str]) -> Optional[str]: | |||
|
|
|||
There was a problem hiding this comment.
Current main already has SessionDB.get_next_title_in_lineage() for numbered title allocation. Please rebase the duplicate-title behavior onto that existing API and the scheduler finalizer, rather than adding a second allocator in the session-creation path.
|
Thanks for the contribution — this was the earliest PR (April 23) to target meaningful cron session titles, and the need was real. Closing as superseded by main's design plus PR #66058: main now titles cron sessions in the scheduler's finally block after the run (deliberate — a create-time title would be overwritten by the agent's own INSERT bookkeeping, and loses the timestamp suffix that keeps repeated runs unique against the title index). #66058 hardened that path with collision dedup and a non-blank guarantee. The job-name-as-title outcome you wanted is what ships today; the mechanism just moved to the other end of the run. |
Problem
Cron job sessions previously had no title in the SQLite session store, causing the web UI and sessions list to display truncated system prompt text as session titles:
This happens because cron sessions bypass the gateway/CLI — they call agent.run_conversation() directly, so the maybe_auto_title() hook is never triggered. The web UI falls back to the first message content (session.preview) when title is NULL.
Solution
Pass the cron job's human-readable name through to SessionDB.create_session() so each cron session gets a meaningful title immediately: wiki-auto-ingest, Hermes Tips, AI docs vault updater, etc.
Changes
Testing