agentgraph run command is the right tool for one-off executions, but production pipelines usually need to run on a schedule, respond to external events, or both. dagraph provides two commands for this: schedule runs a DAG on a cron schedule and blocks until you stop it, and serve starts a long-running HTTP server that accepts webhook triggers and optionally also runs on a cron. This guide covers both.
Prerequisites
Bothschedule and serve require the serve extras package, which adds APScheduler and Uvicorn:
- uv
- pip
agentgraph schedule or agentgraph serve without the extras installed, dagraph prints a clear error message with the install command.
Running on a cron schedule
Useagentgraph schedule to run a DAG repeatedly on a cron expression. The command blocks until you press Ctrl+C — run it under a process manager (systemd, supervisor, Docker) in production.
research.yaml DAG every 6 hours on the hour.
Cron syntax
dagraph uses standard 5-field cron syntax:minute hour day month weekday.
| Expression | Meaning |
|---|---|
0 */6 * * * | Every 6 hours on the hour |
0 9 * * 1-5 | 9 AM Monday–Friday |
*/15 * * * * | Every 15 minutes |
0 0 * * * | Midnight every day |
Non-overlapping execution
dagraph enforces that only one instance of a DAG runs at a time. If a tick fires while a previous run is still in progress, the tick is skipped and a warning is logged:Webhook triggers with agentgraph serve
agentgraph serve starts a lightweight HTTP server that triggers a DAG run on each incoming POST request. The JSON body of the request becomes the DAG inputs.
run_id stored under runs/.
Merging static and webhook inputs
Pass--input flags to serve to provide static defaults. Webhook body keys are merged on top, so the webhook caller can override specific inputs without having to send everything:
{"topic": "AI safety"} results in the inputs:
topic="AI safety", backend="api", max_words="500".
Securing the webhook with Bearer auth
Use--webhook-secret to require an Authorization: Bearer <secret> header on every request. Requests without the correct header receive a 401 response and do not trigger a run:
AGENTGRAPH_WEBHOOK_SECRET environment variable instead of passing it as a flag — this keeps secrets out of your shell history and process list.
Combining webhook and cron
Pass both--webhook and --cron to serve to run on both triggers simultaneously from a single process:
Changing the bind address and port
By defaultserve listens on 127.0.0.1:8000. Change this with --host and --port:
Lifecycle hooks as an alternative notification mechanism
If you need to notify an external system when a scheduled run completes (send a Slack message, write to a database, trigger a downstream pipeline), use lifecycle hooks instead of polling the run status. Add ahooks section to your DAG YAML:
| Event | Fires when |
|---|---|
on_dag_start | The scheduler begins executing the first wave |
on_dag_complete | All nodes completed successfully |
on_dag_paused | An approval_gate or user_input node paused the run |
on_dag_failed | Any node failed and the run halted |
on_node_start | A specific node begins executing |
on_node_complete | A specific node finishes successfully |
on_node_failed | A specific node fails |
${VAR} environment variable expansion in both the URL and headers, so you can keep secrets out of the YAML file. Hook failures are logged as warnings and never fail the DAG.
Human approval gates
Use approval gates to pause scheduled runs for human review before continuing.
Parallel agents
Build the fan-out DAGs that your scheduled and webhook-triggered runs execute.