Skip to content

feat: support name-based lookup for cron job operations#2627

Closed
buntingszn wants to merge 1 commit into
NousResearch:mainfrom
buntingszn:feat/cron-name-lookup
Closed

feat: support name-based lookup for cron job operations#2627
buntingszn wants to merge 1 commit into
NousResearch:mainfrom
buntingszn:feat/cron-name-lookup

Conversation

@buntingszn

Copy link
Copy Markdown
Contributor

Summary

  • get_job() now accepts a job name in addition to the hex ID, with case-insensitive fallback
  • All mutation functions (trigger_job, pause_job, resume_job, remove_job) resolve to canonical ID before operating
  • Tool handler in cronjob_tools.py normalizes job_id early to prevent NoneType errors downstream

Before: hermes cron run my_job_nameJob with ID 'my_job_name' not found
After: hermes cron run my_job_name → resolves to 4b5102fd4c0c, runs successfully

Test plan

  • hermes cron run <job_name> triggers the job
  • hermes cron run <job_id> still works (no regression)
  • hermes cron pause <job_name> / resume / remove all resolve correctly
  • Non-existent name returns clear error message
  • Case-insensitive: hermes cron run MY_JOB_NAME matches my_job_name

🤖 Generated with Claude Code

All cron job operations (run, pause, resume, remove, update) now accept
a job name in addition to the hex job ID. get_job() tries exact ID match
first, then falls back to case-insensitive name match.

Callers resolve to canonical ID before passing to mutation functions,
preventing the NoneType error that occurred when trigger_job/update_job
received a name string instead of an ID.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added comp/cron Cron scheduler and job management P3 Low — cosmetic, nice to have type/feature New feature or request labels May 3, 2026
teknium1 pushed a commit that referenced this pull request May 15, 2026
Cron mutation operations (run/pause/resume/remove) and 'hermes cron edit'
now accept a job name in addition to the hex ID, with case-insensitive
matching. Before this, 'hermes cron run my_job_name' died with
'Job with ID my_job_name not found' and forced the user to look up the
hex ID first.

The original PR matched by name but silently picked the first match when
two jobs shared a name. This version refuses to act on an ambiguous name
and surfaces every matching job (id, name, schedule, next_run_at) so the
caller can pick a specific ID.

- cron/jobs.py:
  - get_job() stays ID-only (preserves existing call-site semantics for
    web_server/api_server/curator/scheduler/test code that always passes
    real IDs).
  - resolve_job_ref() is the new name-or-ID resolver, used by pause/
    resume/trigger/remove_job. Exact ID match wins over a name match
    even if a different job's name happens to equal that ID. Ambiguous
    name match raises AmbiguousJobReference with all candidate IDs.
- tools/cronjob_tools.py: dispatch site uses resolve_job_ref, surfaces
  ambiguous matches as a structured error with the matching IDs.
- hermes_cli/cron.py: 'cron edit' uses resolve_job_ref so editing by
  name works and ambiguous names are reported with IDs.
- tests/cron/test_jobs.py: new TestResolveJobRef covering ID match,
  case-insensitive name match, ID-wins-over-name, ambiguous refusal,
  and that pause/resume/trigger/remove all refuse on ambiguity.

Closes #2627
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #26231 — your substantive change was cherry-picked onto current main with your authorship preserved (commit 6682f91). Branch was 3238 files stale so a direct merge wasn't possible; I salvaged the real ~25 LOC and dropped the unsolicited reformatting.

One hardening on top: name collisions are now refused with a clear error listing every matching job ID, instead of silently picking the first match. Job names aren't unique, so the silent-pick path could mutate the wrong job. The agent tool surfaces the candidate IDs/names/schedules so the model can disambiguate; the CLI prints them.

Thanks for the contribution!

DIZ-admin pushed a commit to DIZ-admin/hermes-agent that referenced this pull request May 16, 2026
Cron mutation operations (run/pause/resume/remove) and 'hermes cron edit'
now accept a job name in addition to the hex ID, with case-insensitive
matching. Before this, 'hermes cron run my_job_name' died with
'Job with ID my_job_name not found' and forced the user to look up the
hex ID first.

The original PR matched by name but silently picked the first match when
two jobs shared a name. This version refuses to act on an ambiguous name
and surfaces every matching job (id, name, schedule, next_run_at) so the
caller can pick a specific ID.

- cron/jobs.py:
  - get_job() stays ID-only (preserves existing call-site semantics for
    web_server/api_server/curator/scheduler/test code that always passes
    real IDs).
  - resolve_job_ref() is the new name-or-ID resolver, used by pause/
    resume/trigger/remove_job. Exact ID match wins over a name match
    even if a different job's name happens to equal that ID. Ambiguous
    name match raises AmbiguousJobReference with all candidate IDs.
- tools/cronjob_tools.py: dispatch site uses resolve_job_ref, surfaces
  ambiguous matches as a structured error with the matching IDs.
- hermes_cli/cron.py: 'cron edit' uses resolve_job_ref so editing by
  name works and ambiguous names are reported with IDs.
- tests/cron/test_jobs.py: new TestResolveJobRef covering ID match,
  case-insensitive name match, ID-wins-over-name, ambiguous refusal,
  and that pause/resume/trigger/remove all refuse on ambiguity.

Closes NousResearch#2627
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Cron mutation operations (run/pause/resume/remove) and 'hermes cron edit'
now accept a job name in addition to the hex ID, with case-insensitive
matching. Before this, 'hermes cron run my_job_name' died with
'Job with ID my_job_name not found' and forced the user to look up the
hex ID first.

The original PR matched by name but silently picked the first match when
two jobs shared a name. This version refuses to act on an ambiguous name
and surfaces every matching job (id, name, schedule, next_run_at) so the
caller can pick a specific ID.

- cron/jobs.py:
  - get_job() stays ID-only (preserves existing call-site semantics for
    web_server/api_server/curator/scheduler/test code that always passes
    real IDs).
  - resolve_job_ref() is the new name-or-ID resolver, used by pause/
    resume/trigger/remove_job. Exact ID match wins over a name match
    even if a different job's name happens to equal that ID. Ambiguous
    name match raises AmbiguousJobReference with all candidate IDs.
- tools/cronjob_tools.py: dispatch site uses resolve_job_ref, surfaces
  ambiguous matches as a structured error with the matching IDs.
- hermes_cli/cron.py: 'cron edit' uses resolve_job_ref so editing by
  name works and ambiguous names are reported with IDs.
- tests/cron/test_jobs.py: new TestResolveJobRef covering ID match,
  case-insensitive name match, ID-wins-over-name, ambiguous refusal,
  and that pause/resume/trigger/remove all refuse on ambiguity.

Closes NousResearch#2627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants