← Back to all spotlights

Trigger.dev v3: Open-Source Background Jobs for TypeScript AI Agents

Tackle serverless timeouts and build resilient, long-running TypeScript AI agents with Trigger.dev v3, the open-source background jobs engine.

P24
By Pickwise24 Editorial Team
Verified Open-Source Review

There is a special circle of developer purgatory reserved for anyone who has watched an autonomous AI agent hit a 60-second serverless timeout. Your LLM was halfway through synthesizing a sprawling web research tree, third tool call in, utterly oblivious to the clock, only for Vercel or AWS Lambda to unceremoniously sever its head with a FUNCTION_INVOCATION_TIMEOUT.

Building agentic loops inside standard HTTP request lifecycles is a recipe for heartbreak. Yet setting up traditional alternatives—wrestling with Redis brokers via BullMQ or decoding Temporal’s notoriously steep learning curve—often feels like bringing an industrial concrete mixer to plant a window box.

Enter Trigger.dev, an open-source background jobs framework purpose-built for TypeScript developers who want durable execution without having to pivot careers into full-time queue infrastructure engineers.


+-------------------+      HTTP Trigger      +------------------------+
| Next.js / Node.js | ---------------------> | Trigger.dev Cloud / OSS|
|    Application    |                        |    Task Orchestrator   |
+-------------------+                        +------------------------+
                                                         |
                             Durable Task Execution      v
                                             +------------------------+
                                             |  Long-Running Worker   |
                                             | - LLM Multi-step Tools |
                                             | - Checkpoint & Resumes |
                                             | - Zero Function Timeout|
                                             +------------------------+

What Is Trigger.dev?

Trigger.dev is a full-stack, code-first background task orchestrator written in TypeScript. Unlike message queues that treat jobs as ephemeral packets of unformatted JSON, Trigger.dev lets you write regular asynchronous TypeScript functions that can run for seconds, hours, or entire days without dying to an API gateway timeout.

Core Architectural Concepts

  • Execution Engine: Runs separate from your web application server, pulling jobs into containerised worker sandboxes.
  • Checkpoint & Resume: Allows tasks to suspend execution while awaiting external responses or sleeps without burning active compute cycles.
  • Native OpenTelemetry: Every run automatically structures traces, spans, and child step calls in a sleek dashboard out of the box.
  • Zero Infrastructure Tax: Works entirely within your existing git repository, avoiding complex custom microservice deployments.

The Landscape: Why BullMQ and Serverless Stumble

Online developer spaces frequently feature lively debates regarding whether BullMQ, Temporal, or hosted queue services are best for running autonomous LLM tasks. BullMQ is brilliant, but you must provision, monitor, and scale your own Redis instances, deal with connection limits, and write bespoke logic whenever tasks fail halfway through an expensive API loop.

FeaturePlain Serverless (Vercel/Lambda)BullMQ + RedisTemporalTrigger.dev v3
Max Execution Time15s – 15m hard limitUnlimited (server-bound)UnlimitedUnlimited
Setup ComplexityZero (until it crashes)Moderate (self-host Redis)High (JVM/Go roots)Low (framework native)
Language FocusPolyglotNode.jsPolyglotTypeScript-first
AI Step ObservabilityBasic logsManual loggingComplex setupOut of the box
Cost ProfilePunitive for idle waitingFixed infrastructureHeavy host foot-printCompute on task run

Trigger.dev v3 strips away the boilerplate. It provides real-time streaming logs, task progress notifications, and dead-simple retries with backoff strategies directly inside standard Next.js, Remix, or vanilla Node projects.


Hands-On: Orchestrating an AI Agent Workflow

Getting started takes less than two minutes. From the root of your existing TypeScript project, run the CLI:


npx trigger.dev@latest init

This creates a trigger.config.ts configuration file and wires up the project dependencies. Let’s define a durable agent task that calls an LLM, scrapes arbitrary web pages, and runs as long as it needs:


// src/trigger/agentPipeline.ts
import { task, wait } from "@trigger.dev/sdk/v3";

export const researchAgentTask = task({
  id: "ai-research-agent",
  // Configure retry behaviour for unstable third-party APIs
  retry: {
    maxAttempts: 4,
    factor: 2,
    minTimeoutInMs: 2000,
  },
  run: async (payload: { query: string; maxDepth: number }) => {
    // Step 1: Initial reasoning query
    const searchPlan = await triggerStep("generate-plan", async () => {
      return { queries: [`${payload.query} trends`, `${payload.query} breakdown`] };
    });

    const gatheredContext: string[] = [];

    // Step 2: Iterate over steps without worrying about gateway drops
    for (const subQuery of searchPlan.queries) {
      // Intentionally wait to respect third-party rate limits
      await wait.for({ seconds: 3 });

      const result = await fetch(`https://api.example.com/search?q=${encodeURIComponent(subQuery)}`);
      gatheredContext.push(await result.text());
    }

    // Step 3: Final synthesis
    return {
      status: "completed",
      sourceCount: gatheredContext.length,
      summary: "Synthesis complete without timeout errors.",
    };
  },
});

async function triggerStep<T>(name: string, fn: () => Promise<T>): Promise<T> {
  return await fn();
}

Triggering this from any route handler—say, an ordinary Next.js Server Action—is non-blocking and instant:


// app/api/trigger/route.ts
import { NextResponse } from "next/server";
import { researchAgentTask } from "@/trigger/agentPipeline";

export async function POST(req: Request) {
  const body = await req.json();
  
  // Fire and forget: the agent runs in background infrastructure
  const handle = await researchAgentTask.trigger({
    query: body.query,
    maxDepth: 3,
  });

  return NextResponse.json({ jobId: handle.id });
}

Why Trigger.dev Stands Out

  • First-Class TypeScript DX: You get full autocomplete across triggers, payload types, and child task payloads without running code generators.
  • True Local Development: The CLI spins up a local execution bridge. You can set breakpoints inside your background tasks in VS Code and inspect runs while working locally.
  • Self-Hostable or Managed: You can self-host the entire core platform via Docker Compose or use their cloud tier.
  • Resilient to Downtime: If your web server restarts, your running tasks remain intact inside the execution engine.

If you are building AI agents, document parsers, media pipelines, or anything else in the TypeScript ecosystem that dares to run longer than standard web requests permit, Trigger.dev solves the timeout problem elegantly.

🛡️ Editorial Standards & Methodology

Every repository featured on Pickwise24 undergoes testing on local workstation hardware before publication. We verify CLI installation steps, review open-source repository licensing, benchmark computational footprint, and evaluate architectural trade-offs to provide genuine, high-utility developer intelligence.