Background Execution

Conceptual

Long-running, scheduled and event-triggered work.

Tasks do not require an open connection. Submit an objective, disconnect, and collect the outcome later via polling, webhook or stream replay.

Execution modes#

ModeTriggerTypical duration
InteractiveAPI call with an open streamSeconds to minutes
DetachedAPI call, result collected laterMinutes to hours
ScheduledCron expression or intervalRecurring
Event-drivenInbound webhook or connector eventOn demand
ContinuousStanding objective re-evaluated on new dataOngoing, budget-capped
Scheduled monitoring task
await pimsy.tasks.create({
  objective:
    class="tok-str">"Every weekday at class="tok-num">07:class="tok-num">00 UTC, summarize overnight error-rate anomalies across production services " +
    class="tok-str">"and post a digest to the incident channel. Escalate only if p99 error rate exceeds class="tok-num">2%.",
  schedule: { cron: class="tok-str">"class="tok-num">0 class="tok-num">7 * * class="tok-num">1-class="tok-num">5", timezone: class="tok-str">"UTC" },
  capabilities: [class="tok-str">"connector.datadog", class="tok-str">"connector.slack"],
  budget: { steps: class="tok-num">25, usd: class="tok-num">2.5 },
  approvals: { required: [] }
});

Collecting results#

  • Poll GET /v1/tasks/{id} for status and artifacts.
  • Receive a callback on completion, failure or approval request — see Webhooks.
  • Replay the event log from any offset — see Streaming.

Last updated 2026-09-04