Skip to content

Add scheduled agents with cron execution and webhook triggers#72

Merged
emal-avala merged 6 commits intomainfrom
feat/scheduled-agents
Apr 6, 2026
Merged

Add scheduled agents with cron execution and webhook triggers#72
emal-avala merged 6 commits intomainfrom
feat/scheduled-agents

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

  • agent schedule subcommand — full CRUD for persistent schedules (add, list, run, remove, enable, disable)
  • agent daemon — background cron loop checking schedules every 30 seconds, executing due jobs
  • Webhook triggers — optional --webhook-port on daemon starts an HTTP server; external systems POST to /trigger?secret=<key> to invoke schedules on demand
  • Per-schedule config — model override, cost limits, turn limits, permission mode
  • Session persistence — each run creates a session resumable via /resume <id>
  • Cron parser — built-in 5-field cron with *, */N, N-M, N,M support + next_after() for computing next fire time

Example usage

agent schedule add "0 9 * * *" --prompt "run tests and fix failures" --name daily-tests --webhook
agent schedule add "0 */6 * * *" --prompt "check for security updates" --name security-scan --max-cost 0.50
agent schedule list
agent schedule run daily-tests
agent daemon --webhook-port 8090

# External trigger:
curl -X POST http://localhost:8090/trigger?secret=<webhook_secret>

Architecture

~/.config/agent-code/schedules/*.json   ← persisted schedule definitions
agent daemon                            ← checks every 30s, runs matching schedules
  └─ ScheduleExecutor.run_once()        ← creates QueryEngine, runs prompt, saves session
agent daemon --webhook-port 8090        ← also starts Axum webhook server
  └─ POST /trigger?secret=<key>         ← finds schedule by secret, runs it

Test plan

  • 18 new unit tests passing (cron parsing, storage CRUD, webhook lookup, serialization)
  • All 262 existing tests still passing
  • cargo clippy clean (0 warnings)
  • cargo fmt --check clean
  • CI passes on this PR

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread crates/cli/src/main.rs Fixed
Comment thread crates/cli/src/main.rs Fixed
emal-avala and others added 4 commits April 6, 2026 00:37
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New `agent schedule` subcommand for managing persistent schedules
and `agent daemon` for running the cron loop. Schedules are stored
as JSON in ~/.config/agent-code/schedules/ and support per-job
model overrides, cost limits, and turn limits.

CLI:
  agent schedule add "0 9 * * *" --prompt "run tests" --name daily
  agent schedule list
  agent schedule run daily
  agent schedule enable/disable daily
  agent schedule remove daily
  agent daemon --webhook-port 8090

Webhook triggers via POST /trigger?secret=<key> allow external
systems (CI, GitHub Actions, monitoring) to invoke schedules.
Each run creates a session resumable via /resume <id>.

Includes 18 new tests covering cron parsing, schedule storage
CRUD, webhook secret lookup, and serialization roundtrips.
14 new E2E tests covering the full schedule CRUD lifecycle via
the compiled binary. No API key needed — tests run fast in CI.

Also moves schedule add to the early (no-LLM) path and skips
the setup wizard when a subcommand is present, fixing a panic
in non-TTY environments.
@emal-avala emal-avala force-pushed the feat/scheduled-agents branch from 73c99c7 to d556e48 Compare April 6, 2026 07:40
@emal-avala emal-avala added the run-e2e Trigger E2E test suite on this PR label Apr 6, 2026
Both flagged values are intentionally user-facing output:
- Webhook secret shown once at creation (like API key provisioning)
- Session ID is a non-secret UUID prefix needed for /resume
Comment thread crates/cli/src/main.rs Dismissed
Comment thread crates/cli/src/main.rs Fixed
Comment thread crates/cli/src/main.rs Dismissed
@emal-avala emal-avala merged commit 9717b1e into main Apr 6, 2026
12 of 15 checks passed
@emal-avala emal-avala deleted the feat/scheduled-agents branch April 6, 2026 08:29
@emal-avala emal-avala mentioned this pull request Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-e2e Trigger E2E test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants