Skip to content

feat(webhook): cron jobs can fire from app events, not just the clock (ChatGPT Work-inspired) - #95262

Open
teknium1 wants to merge 1 commit into
mainfrom
chatgpt-work-inspired/webhook-cron-triggers
Open

feat(webhook): cron jobs can fire from app events, not just the clock (ChatGPT Work-inspired)#95262
teknium1 wants to merge 1 commit into
mainfrom
chatgpt-work-inspired/webhook-cron-triggers

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

A webhook route can now fire an existing cron job the moment an external event arrives — turning any scheduled job into an event-triggered task instead of a polling loop.

Inspired by ChatGPT Work's August 25, 2026 release (OpenAI release notes, learn.chatgpt.com what's new): scheduled tasks there can now respond to app events (new Gmail message, Slack channel activity, GitHub PR feedback) via webhooks "without polling on a fixed cadence." Hermes already had both halves — the webhook adapter and the cron subsystem — this PR composes them with a single route key.

How ChatGPT Work does it vs. how this adapts it

ChatGPT Work binds a scheduled task to a first-party app event (Gmail/Slack/GitHub connectors) and pauses approval-requiring actions. Hermes is self-hosted, so the adaptation is provider-agnostic: anything that can POST (GitHub, GitLab, Stripe, Supabase, a monitoring stack, another agent) can fire a job, protected by the webhook adapter's existing HMAC auth, rate limiting, events/filters/script filtering, and idempotency. The job keeps its own prompt, skills, model pin, and delivery target; the rendered route prompt is injected as transient per-run context on the exact same rail as cronjob(action='run', prompt=...) — the stored job is never mutated, and the fire goes through the scheduler's at-most-once claim so a webhook burst can't double-fire a running job.

Changes

  • gateway/platforms/webhook.py: cron_job route mode — fires the referenced job in the background (202 Accepted), after all existing route protections; connect-time validation rejects cron_job + deliver_only (mutually exclusive)
  • tools/cronjob_tools.py: execute_job_for_event() — public wrapper over the shared claimed-run body (_execute_job_now), so event fires share claiming, in-flight dedupe, delivery, and [SILENT] handling with scheduler/manual runs
  • hermes_cli/webhook.py + hermes_cli/subcommands/webhook.py: hermes webhook subscribe --cron-job <id|name> with create-time job-ref validation (canonicalized to the job ID); list/subscribe output shows the trigger mode
  • Docs: webhooks.md route table + new "Event-Triggered Cron Jobs" section, cron.md capability list; zh-Hans mirrors for both
  • Tests: tests/gateway/test_webhook_cron_trigger.py (6), CLI tests in test_webhook_cli.py (3)

Validation

Check Result
New adapter + unit tests 6/6 pass
New CLI tests 3/3 pass
Sibling webhook suites (adapter, deliver_only, dynamic routes, CLI) 60/60 pass
E2E (real temp HERMES_HOME, real job store, real claim path) fire + unknown-ref + paused-job all correct
Live repro — zero mocks: real no_agent script job created in a temp HERMES_HOME, real HTTP POST to the real adapter job fired, marker file written, last_status: ok
ruff on touched files clean (pre-existing format drift in webhook.py untouched)

Not applied to any prior PR — dupe sweep found no open/closed PR covering webhook→cron triggering (nearest: #491 webhook-triggered sessions, which the existing agent-mode routes already cover; this adds the existing-job trigger half).

Infographic

Event-Triggered Cron Jobs

ChatGPT Work's Aug 25 2026 release lets scheduled tasks fire from app
events (new Gmail message, Slack activity, GitHub PR feedback) instead
of polling on a cadence. This ports the pattern by composing two
existing Hermes subsystems: a webhook route can now set cron_job to
fire an existing cron job on each inbound event.

- gateway/platforms/webhook.py: cron_job route mode — after the same
  HMAC auth / rate limit / filters / script / idempotency as agent
  routes, the rendered prompt becomes transient per-run context and the
  job fires through execute_job_for_event on a worker thread (202
  Accepted immediately). Startup validation rejects cron_job +
  deliver_only.
- tools/cronjob_tools.py: execute_job_for_event() — public wrapper over
  the shared claimed-run body (_execute_job_now), so event fires share
  at-most-once claiming, in-flight dedupe, delivery, and [SILENT]
  handling with scheduler and manual runs.
- hermes webhook subscribe --cron-job: creates event-trigger
  subscriptions; job ref validated (and canonicalized to the job ID) at
  create time.
- Docs: webhooks.md route table + Event-Triggered Cron Jobs section,
  cron.md capability list, zh-Hans mirrors.
- Tests: tests/gateway/test_webhook_cron_trigger.py (adapter + unit),
  CLI tests in test_webhook_cli.py.
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 1efa74e — Inspired by ChatGPT Work: event-triggered cron jobs via webh

⚠️ Warnings

OSV vulnerability scan · View job

7 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 3m56s vs 3m53s (+1.3%). 3 job(s) slower, 8 faster, 2 unchanged.

  • OSV scan / Scan lockfiles / osv-scan: -7.0s
  • OS-specific tests / macOS-only tests: +7.0s
  • Python tests / Run tests: -6.0s
  • OSV scan / Emit review status: -3.0s
  • Detect affected areas: +3.0s

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management platform/webhook Webhook / API server sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 26, 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 comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/webhook Webhook / API server sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants