Cette page est affichée en anglais. Une traduction française est en cours.
WorkflowsApr 3, 2026·2 min de lecture

Trigger.dev — Background Jobs for AI Agents

Open-source framework for long-running AI agent tasks, workflows, and scheduled jobs. Built-in retries and observability. 14K+ stars.

Introduction

Trigger.dev is an open-source background job framework with 14,300+ GitHub stars purpose-built for long-running AI tasks. It handles what serverless functions can't — agent workflows that run for minutes or hours, multi-step pipelines with retries, scheduled batch processing, and event-driven automation. With built-in observability (trace every step), automatic retries, rate limiting, and concurrency control, Trigger.dev is the infrastructure layer between your AI logic and reliable production execution. Deploy your own or use their managed cloud.

Works with: Node.js, TypeScript, OpenAI, Anthropic, any API, Vercel, Next.js, Express. Best for teams running AI agents, batch processing, or multi-step workflows that exceed serverless time limits. Setup time: under 5 minutes.


Trigger.dev for AI Workloads

Why Background Jobs for AI?

Serverless functions have 10-60s time limits. AI workloads often need:

  • Agent loops that run for minutes (research, code generation)
  • Batch processing of 1000s of documents through LLMs
  • Multi-step pipelines with retries on each step
  • Scheduled tasks (daily report generation, model retraining)

AI Agent Workflow Example

import { task } from '@trigger.dev/sdk/v3';

export const codingAgent = task({
    id: 'coding-agent',
    maxDuration: 600, // 10 minutes
    run: async ({ issue }: { issue: string }) => {
        // Multi-step agent loop
        let plan = await callLLM(`Plan how to fix: ${issue}`);
        let code = await callLLM(`Write code for: ${plan}`);
        let tests = await runTests(code);

        // Retry loop if tests fail
        for (let i = 0; i < 3 && !tests.passed; i++) {
            code = await callLLM(`Fix failing tests: ${tests.errors}`);
            tests = await runTests(code);
        }

        return { code, testsPassed: tests.passed };
    },
});

Batch Processing

export const batchEmbed = task({
    id: 'batch-embed',
    run: async ({ documents }: { documents: string[] }) => {
        const results = await Promise.all(
            documents.map(doc =>
                callOpenAI(`Generate embedding for: ${doc.slice(0, 1000)}`)
            )
        );
        await saveEmbeddings(results);
        return { processed: documents.length };
    },
});

// Trigger with 10,000 documents
await batchEmbed.trigger({ documents: allDocs });

Scheduled Jobs

import { schedules } from '@trigger.dev/sdk/v3';

export const dailyReport = schedules.task({
    id: 'daily-ai-report',
    cron: '0 9 * * *', // Every day at 9 AM
    run: async () => {
        const metrics = await getYesterdayMetrics();
        const report = await callLLM(`Generate daily AI usage report: ${JSON.stringify(metrics)}`);
        await sendEmail({ to: 'team@company.com', body: report });
    },
});

Built-in Observability

Every task execution is traced:

  • Step-by-step execution timeline
  • Input/output for each step
  • Error details with stack traces
  • Duration and retry history
  • Cost tracking (if configured)

FAQ

Q: What is Trigger.dev? A: Trigger.dev is an open-source background job framework with 14,300+ GitHub stars for running long-duration AI tasks, multi-step workflows, batch processing, and scheduled jobs with built-in retries and observability.

Q: How is Trigger.dev different from n8n or Temporal? A: Trigger.dev is code-first TypeScript (not visual/YAML). n8n is a visual workflow builder. Temporal is a distributed workflow engine for large teams. Trigger.dev is the simplest path from "I have a TypeScript function" to "it runs reliably in production."

Q: Is Trigger.dev free? A: Yes, open-source under Apache-2.0. Self-host for free. Managed cloud has a free tier.


🙏

Source et remerciements

Created by Trigger.dev. Licensed under Apache-2.0.

trigger.dev — ⭐ 14,300+

Discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.