Skip to main content

Automations

Automations run cloud agents without a human kicking them off — on a schedule, or when something happens (a new issue, a failing build, a comment). Each automation stores a prompt template, trigger, and scope (repository, team, model) that the platform reuses on every invocation.

Trigger types

The platform supports four trigger kinds in the agents API. Additional sources (Slack, Linear, webhooks) appear in the UI roadmap; GitHub and schedule triggers are the most mature today.

Trigger kindWhen it firesExample
scheduleCron expression in a timezoneEvery weekday at 9:00 AM — triage new issues
githubGitHub webhook event + actionWhen a PR check fails — attempt a fix
manualOne-click run from a templateOn-demand security scan
apiAuthenticated API callCI pipeline invokes automation by ID

Schedule examples

NameCronTimezoneTask
Weekday triage0 9 * * 1-5America/New_YorkReview open issues and label by priority
Nightly dependency audit0 2 * * *UTCScan for outdated packages with known CVEs
Weekly docs refresh0 10 * * 1Europe/LondonUpdate docs for code changed in the last 7 days

GitHub event examples

EventActionAutomation behavior
pull_requestopenedRun a bug-finding pass on the diff
check_runcompleted (conclusion: failure)Attempt to fix failing tests
issue_commentcreated (contains /agent fix)Start a targeted fix run
pushmain branchRegenerate API docs after merge

Trigger payload shape

Automations store triggers as JSON. Examples matching the platform contract:

{
  "kind": "schedule",
  "cron": "0 9 * * 1-5",
  "timezone": "America/New_York"
}
{
  "kind": "github",
  "event": "check_run",
  "action": "completed"
}
{
  "kind": "manual"
}

Built-in templates

The Agents workspace ships starter templates you can customize:

TemplateTriggers (UI)Purpose
Find bugsScheduled, Slack, GitHubDeep review of recent commits for high-severity bugs
Scan codebase for vulnerabilitiesScheduled, SlackScheduled security review with alerts
Generate docsScheduled, Slack, GitHubUpdate developer docs for changed code
Add test coverageScheduled, Slack, GitHubAdd tests for high-risk uncovered logic
Incident triageScheduled, Slack, SentrySummarize production signals and next steps
Research changed APIsScheduled, GitHub, WebTrack dependency and API changes
Slack triggers

Slack appears as a trigger option in the UI, but the Slack integration is not fully connectable in the dashboard yet. Use GitHub or schedule triggers for production automations today. See Troubleshooting.

Defining an automation

  1. Choose a trigger

    Pick a schedule or a GitHub event from a connected integration. For schedules, set cron, timezone, and confirm the next run time shown in the UI.

  2. Describe the task

    Write the instruction the agent should follow each time it runs. Be specific about scope, severity thresholds, and what to do when nothing is found ("report no issues" vs. stay silent).

  3. Set repository and branch

    Scope the automation to a single repository. The agent clones from your configured base branch unless the trigger provides a ref (for example, a PR head SHA).

  4. Configure model and approvals

    Choose the model and approval policy. High-impact automations (auto-opening PRs) should use stricter approval settings than read-only triage.

  5. Enable and monitor

    Start in draft, run manually once, then set status to enabled. Watch the first few runs in Sentinel before widening scope.

Create an automation via API

Automations are managed through the agents API. Requests require an authenticated session scoped to your organization.

curl -X POST "https://agents-api.4rged.ai/api/automations" \
  -H "Authorization: Bearer <session-access-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "repositoryId": "42",
    "name": "Fix failing CI",
    "promptTemplate": "When CI fails on a PR, inspect the failing check logs, implement a minimal fix, and open a PR if confident.",
    "status": "draft",
    "trigger": {
      "kind": "github",
      "event": "check_run",
      "action": "completed"
    },
    "agentKind": "cloud"
  }'

List automations for an organization:

curl "https://agents-api.4rged.ai/api/automations?organizationId=org_abc123" \
  -H "Authorization: Bearer <session-access-token>"

Automation lifecycle

StatusBehavior
draftConfigured but does not fire on triggers
enabledActive — fires on schedule or events
disabledPaused — retains config, no new runs
archivedRetired — hidden from default lists

API permissions and agent kinds

Creating automations through POST /api/automations on agents-api.4rged.ai requires an authenticated session with agent manager capability for the target organization. The handler persists records in x4rge_agent_automations with a required name and promptTemplate; new automations default to draft unless enabled: true is sent. The agentKind field accepts general, reviewer, tester, fixer, or pr_assistant — matching cloud run kinds in packages/platform-contracts. Each creation writes an audit event for operator review.

Best practices

Idempotent instructions

Write prompts that behave safely when run repeatedly. For example, "If a fix PR already exists for this failure, comment on it instead of opening a duplicate."

  • Start automations in a low-stakes repository and review their output before widening scope.
  • Cap concurrent runs per automation to avoid duplicate PRs on the same failure.
  • Pair automations with budget policies so runaway triggers can't exhaust allowance.
  • Log automation IDs in run metadata so Sentinel can correlate runs to their source.