# Automate agent runs

Source: https://agenta.ai/docs/reference/agents/automate-agent-runs

Agenta automations start agent runs on a schedule or when a connected provider emits an event. They are not session-completion webhooks.

## Scheduled run

Create a trigger schedule with a five-field UTC cron expression:

```json
{
  "schedule": {
    "name": "Weekday support digest",
    "description": "Summarize new support work every weekday.",
    "data": {
      "event_key": "weekday-support-digest",
      "schedule": "0 8 * * 1-5",
      "inputs_fields": {
        "messages": [
          {
            "role": "user",
            "content": "Prepare today's support digest."
          }
        ]
      }
    }
  }
}
```

`start_time` and `end_time` optionally bound the active UTC window. When the agent creates a schedule with the `create_schedule` platform tool, Agenta binds it to the current workflow variant. The dispatcher resolves that variant's latest revision each time the schedule fires, so later commits change future runs.

To keep execution stable, create the schedule through `POST /api/triggers/schedules/` and set `schedule.data.references.workflow_revision` to a specific revision `id` or `version`. A `workflow_revision` reference remains pinned; a `workflow` or `workflow_variant` reference tracks its latest revision.

## Provider event

A subscription requires a ready provider connection, an event key from the trigger catalog, and event-specific `trigger_config`:

```json
{
  "subscription": {
    "name": "Triage new issues",
    "connection_id": "019d952f-0000-0000-0000-000000000020",
    "data": {
      "event_key": "github_issue_created",
      "trigger_config": { "owner": "acme", "repo": "product" },
      "inputs_fields": {
        "messages": [{ "role": "user", "content": "Triage this new issue." }]
      },
      "include_event": true
    }
  }
}
```

Confirm the catalog event's integration and description before saving it. Event matching is provider-specific.

`include_event` defaults to `true`. With it on, Agenta adds the event to the last user message: a line `Event data (<event type>):`, then the event's `attributes` as a JSON block. Set it to `false` to send the message alone. A delivery that runs or tests the subscription records the event in `data.event`. Older deliveries, and refusals before the event is read, do not have it.

## Input mapping

A leaf beginning with `$` is a JSONPath selector over the fire context; a leaf beginning with `/` is a JSON Pointer. Other strings pass through literally. Unmatched selectors resolve to `null`; selectors are not interpolated inside larger strings.

Include an explicit imperative `messages` entry. The agent reads only `messages`, so a sibling key such as `payload` never reaches it. To put one event field inside the text, write the content as text parts with one selector per part:

```json
{
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "Triage the issue titled: " },
        { "type": "text", "text": "$.event.attributes.issue.title" }
      ]
    }
  ]
}
```

On a subscription, a message text that is not a string is sent as text: a number or an object as its JSON, and an unmatched selector as an empty string. See [Automations](https://agenta.ai/docs/concepts/automations.md) for setup and delivery monitoring.
