feat(cron): conditional triggers for cron jobs#2654
Closed
iankar8 wants to merge 1 commit into
Closed
Conversation
Add a $0 pre-run gate for cron jobs. Before spawning an AIAgent (which
costs real money), evaluate a lightweight trigger condition. If the
trigger returns false, the job is skipped and rescheduled — no LLM
call, no tokens burned.
Three trigger types:
- **sql**: Run a read-only query against state.db. Skip if result is
below a configurable threshold (default: 1). Useful for "only run if
there are new messages/sessions since last check."
- **file_changed**: Check file mtime against the job's last_run_at.
Skip if the file hasn't been modified. Useful for "only summarize
the feed when it has new data."
- **command**: Run a shell command with 10s timeout. Skip if exit code
is non-zero. Useful for arbitrary external conditions like flag files
or API health checks.
Mutations (INSERT/UPDATE/DELETE/DROP) are blocked in SQL triggers.
Trigger failures are fail-closed (skip the job, don't waste money).
Examples:
cronjob(action="create",
prompt="Summarize new conversations",
schedule="every 2h",
trigger={"type": "sql",
"query": "SELECT COUNT(*) FROM messages WHERE timestamp > strftime('%s','now','-2 hours')",
"threshold": 1})
cronjob(action="create",
prompt="Process updated data",
schedule="every 30m",
trigger={"type": "file_changed",
"path": "~/data/feed.json"})
cronjob(action="create",
prompt="Run analysis",
schedule="0 9 * * *",
trigger={"type": "command",
"command": "test -f /tmp/new-data-ready"})
teknium1
added a commit
that referenced
this pull request
May 15, 2026
Adds three pre-run gate recipes to the cron docs: - file-change gate (stat + mtime + state file) - external-flag gate (file presence) - SQL-count gate (user's own database, not state.db) These are the use cases @iankar8 proposed adding as a parallel 'trigger' subsystem in #2654. The existing `script` + `wakeAgent` gate already covers all three at $0 — this lands the patterns as documentation so users can find them, instead of adding a second gating mechanism to the cron subsystem.
Contributor
|
Thanks for the careful writeup @iankar8 — the trigger use cases here are real, but Hermes-Agent already ships a $0 pre-run gate that covers all three: a cron job's So rather than landing a parallel trigger subsystem, the work from this PR landed as documentation — three worked recipes (file-change, external-flag, SQL-count) in the existing Two extra notes from the review:
Closing in favor of #26229. Appreciate the contribution. |
Author
|
Thanks so much! If you're open to adding me as a coauthor I'd really
appreciate it!
…On Fri, May 15, 2026 at 3:34 AM Teknium ***@***.***> wrote:
Closed #2654 <#2654>.
—
Reply to this email directly, view it on GitHub
<#2654 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BHNOKA5UFUTFC2AAGVQF2QL423JC3AVCNFSM6AAAAACW4QVH4SVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMRVGU3DMNZWGY3DONA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
DIZ-admin
pushed a commit
to DIZ-admin/hermes-agent
that referenced
this pull request
May 16, 2026
…ch#26229) Adds three pre-run gate recipes to the cron docs: - file-change gate (stat + mtime + state file) - external-flag gate (file presence) - SQL-count gate (user's own database, not state.db) These are the use cases @iankar8 proposed adding as a parallel 'trigger' subsystem in NousResearch#2654. The existing `script` + `wakeAgent` gate already covers all three at $0 — this lands the patterns as documentation so users can find them, instead of adding a second gating mechanism to the cron subsystem.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…ch#26229) Adds three pre-run gate recipes to the cron docs: - file-change gate (stat + mtime + state file) - external-flag gate (file presence) - SQL-count gate (user's own database, not state.db) These are the use cases @iankar8 proposed adding as a parallel 'trigger' subsystem in NousResearch#2654. The existing `script` + `wakeAgent` gate already covers all three at $0 — this lands the patterns as documentation so users can find them, instead of adding a second gating mechanism to the cron subsystem.
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.
Summary
Adds a lightweight trigger system for cron jobs — a $0 pre-run gate that evaluates a condition before spawning an AIAgent. If the trigger returns false, the job is skipped and rescheduled. No LLM call, no tokens burned.
Problem: Cron jobs run on fixed schedules regardless of whether there's new data to process. A job scheduled
every 30mfires 48 times/day even if only 2 of those runs have meaningful work. The other 46 runs waste inference costs.Solution: An optional
triggerfield on cron jobs that supports three evaluation types:sqlfile_changedcommandExamples
Design decisions
triggerfield run exactly as before. Existing jobs, configs, and the[SILENT]mechanism are untouched.AIAgent,model_tools, gateway, and config are untouched.Files changed
cron/scheduler.py—check_trigger()function + 3 type-specific evaluators, wired intotick()beforerun_job()cron/jobs.py—triggerparam oncreate_job(), persisted in job dicttools/cronjob_tools.py—triggerparam oncronjob()tool + schema updatetests/cron/test_triggers.py— 18 tests covering all trigger types, edge cases, and failure modesTest plan
pytest tests/cron/test_triggers.py)