Skip to content

feat(cron): support name-based lookup for job operations#26231

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-1e50463e
May 15, 2026
Merged

feat(cron): support name-based lookup for job operations#26231
teknium1 merged 2 commits into
mainfrom
hermes/hermes-1e50463e

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #2627 by @buntingszn — cherry-picks the substantive change, drops the unsolicited reformatting (branch was 3238 files stale), and hardens the name-collision case.

What this makes true

hermes cron run|pause|resume|remove|edit <name> and the agent's cronjob tool now accept a job name (case-insensitive) in addition to the hex ID. Currently dies with "Job with ID 'my_job_name' not found" — confirmed on main.

Changes

  • cron/jobs.py:
    • get_job() stays ID-only — preserves semantics for existing callers (web_server, api_server, curator, scheduler, tests) that always pass real IDs.
    • New resolve_job_ref() is the name-or-ID resolver, used by pause_job/resume_job/trigger_job/remove_job. Exact ID match wins over a colliding name match. Ambiguous name match raises AmbiguousJobReference with all candidate IDs.
  • tools/cronjob_tools.py: agent tool surfaces ambiguous matches as a structured error with the matching IDs/names/schedules so the model can pick one.
  • hermes_cli/cron.py: hermes cron edit <name> works; ambiguous names print all matching IDs.
  • tests/cron/test_jobs.py: new TestResolveJobRef (10 tests) covering ID match, case-insensitive name match, ID-wins-over-name, ambiguous-refusal, and that every mutation fn refuses on ambiguity.

Difference from the original PR

@buntingszn's PR silently picked the first match when two jobs shared a name. Names are not unique, so that path can mutate the wrong job. This version refuses with a clear error listing every matching ID.

Validation

Before After
run <job_name> "Job with ID 'job_name' not found" resolves, runs
run <hex_id> works works (no regression)
run <name> with 2 dup names n/a refuses, lists both IDs
tests/cron/test_jobs.py 113 passed 124 passed (10 new)
tests/tools/test_cronjob_tools.py + tests/hermes_cli/test_cron.py green green

Closes #2627

buntingszn and others added 2 commits May 15, 2026 01:33
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
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-1e50463e vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8257 on HEAD, 8251 on base (🆕 +6)

🆕 New issues (3):

Rule Count
invalid-argument-type 3
First entries
run_agent.py:13750: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`
run_agent.py:13753: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown, Unknown] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`
run_agent.py:7482: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`

✅ Fixed issues (3):

Rule Count
invalid-argument-type 3
First entries
run_agent.py:7482: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`
run_agent.py:13750: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`
run_agent.py:13753: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown | str, Unknown | str | dict[str, str]] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`

Unchanged: 4308 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1 teknium1 merged commit 9f57f22 into main May 15, 2026
15 of 17 checks passed
@teknium1 teknium1 deleted the hermes/hermes-1e50463e branch May 15, 2026 08:36
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management comp/cli CLI entry point, hermes_cli/, setup wizard labels May 15, 2026
r266-tech added a commit to r266-tech/hermes-agent that referenced this pull request May 15, 2026
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants