Skip to content

Set human-readable titles for cron run sessions #131

Description

@Interstellar-code

Problem

Cron job runs are persisted as chat sessions with IDs like:

cron_<jobId>_<YYYYMMDD_HHMMSS>

However, those sessions do not get an explicit session title. The first persisted user message is the scheduler-injected cron guidance prefix:

[IMPORTANT: You are running as a scheduled cron job. DELIVERY: ...]

Downstream clients such as Hermes SwitchUI list sessions by title || preview, so cron-run sessions appear with the implementation warning ([IMPORTANT: ...]) instead of a useful name.

Current backend mechanism observed

In cron/scheduler.py:

  • _build_job_prompt() prepends the cron execution/delivery hint to the user prompt.
  • _run_job() creates a session id using cron_{job_id}_{timestamp}.
  • The agent is constructed with platform="cron", session_id=_cron_session_id, and session_db=_session_db.
  • No explicit title is assigned for that cron session.

Result: the session preview/title fallback is polluted by scheduler instructions.

Desired behavior

When the scheduler creates a cron-run session, it should set a deterministic title such as:

<cron job name> — <YYYY-MM-DD HH:mm>

Examples:

daily-brief — 2026-06-10 07:30
ProductHunt Daily Trends — 2026-06-09 15:09

This should happen server-side so every client benefits, not just SwitchUI.

Suggested implementation

After creating/opening the cron session DB row, set the title before or immediately after the run starts:

session_title = f"{job_name}{_hermes_now().strftime('%Y-%m-%d %H:%M')}"
_session_db.set_session_title(_cron_session_id, session_title)

Consider a helper to sanitize/shorten with existing SessionDB.sanitize_title() rules and avoid uniqueness conflicts. If title uniqueness conflicts are possible for repeated/manual reruns within the same minute, include seconds or the short job id suffix.

Acceptance criteria

  • Cron sessions no longer display [IMPORTANT: You are running as a scheduled cron job...] as their visible title.
  • New cron run sessions have titles based on the cron job name and run timestamp.
  • The original prompt/preview remains available for message history/search.
  • Existing session deletion and lookup by cron_<jobId>_* remain compatible.
  • Add/adjust tests covering cron session title creation.

Client-side workaround

SwitchUI can derive friendlier display names from the cron_<jobId>_<timestamp> session key and /api/claude-jobs, but this is only a compatibility workaround. The backend should own the canonical title.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions