A windswept bonsai on a floating island

Get to know Cadenya

We’re developers who love to build. We set out to create a yes-code platform that makes building agents feel like the best parts of building software.

Postgres job queues for AI agents (2026)

Postgres

By Cadenya

pgmq, pg-boss, River, graphile-worker, and Solid Queue all run AI agent jobs on the Postgres you already have: each one claims work with SKIP LOCKED, brings failed work back for another try, and, except for Solid Queue on its default separate database, lets you enqueue in the same transaction as your data. None of them runs the agent loop itself, so the model calls, the event stream, and the wait for a human approval stay in your code, though River Pro workflows can hold a task for an approval signal.

So pick by runtime. Use pg-boss or graphile-worker in Node.js, River in Go (with Java, Ruby, Rust, and TypeScript clients on the same schema), Solid Queue in Rails, and pgmq for plain SQL queues any language can call, as Supabase Queues does. And if you’d rather your queue just start agent runs and handle webhooks, Cadenya is a hosted agent loop with approvals, conversation state, resume, and model swap built in, so a job makes one API call to start an objective. A coding agent can set it up with no account, in a temporary workspace you claim later. What it offers is at the end.

Every price and limit below comes from each vendor’s own pages, checked on November 11, 2026.

pgmq vs pg-boss vs River vs graphile-worker vs Solid Queue for AI agent jobs

pgmqpg-bossRivergraphile-workerSolid QueueCadenya
What it isA Postgres extension: SQL functions and one table per queueA Node.js job queueA Go job queue, with Java, Ruby, Rust, and TypeScript clientsA Node.js job queue you can also call from SQLThe Active Job backend for RailsA hosted agent loop your jobs call
RetriesA message reappears after its visibility timeout, and read_ct counts readsretryLimit, exponential backoff, dead letter queues25 attempts by default, plus snooze25 attempts by default, exponential backoffActive Job retry_onAn External ID on each objective, so a retried job never starts a second run
SchedulingA delay on sendCron and RRULE schedulesScheduled, periodic, and cron jobsrun_at and a crontabDelayed jobs and config/recurring.ymlAgent schedules start objectives on calendar or interval rules
Waiting for a human approvalA message your app sends after the decisionA second job your approve endpoint sendsRiver Pro workflows: a task waits for a signalA second job, which a trigger can addA second job your approve endpoint enqueuesMark a tool for approval, and the loop parks on toolApprovalRequested until your backend decides
What you still buildWorkers, loop, stream, approval screenLoop, stream, approval screenLoop, stream, approval screenLoop, stream, approval screenLoop, stream, approval screenYour tools and the approval decision. The loop, event log, and stream are hosted
LicensePostgreSQL LicenseMITMPL-2.0, plus paid River ProMITMITSDKs under Apache-2.0

The first five are libraries you run next to your app, and the last is a service your jobs call.

Latest versions

The latest releases on each registry and GitHub:

QueuePackageLatest releaseRuns on
pg-bosspg-boss on npm12.38.2, November 10, 2026Node.js 22.12 or Bun, PostgreSQL 13 or later
Rivergithub.com/riverqueue/riverv0.51.2, November 9, 2026go 1.26.0 in go.mod, the three latest PostgreSQL majors
Solid Queuesolid_queue gem1.7.2, November 3, 2026Ruby 3.2 or later, Rails 7.1 or later
graphile-workergraphile-worker on npm0.18.0, September 8, 2026Node.js 22.18 or later, PostgreSQL 12 or later
pgmqpgmq/pgmq on GitHubv1.13.1, October 20, 2026Postgres 14 to 18

River’s riverqueue npm package (0.3.2) and gem (0.16.1) shipped the same day, and “Every language uses the same River schema and migration history.” River Pro’s Go module is at v0.32.0 (October 5).

pg-boss ships @pg-boss/dashboard (1.13.1), and Solid Queue 1.7.0 added batches with callbacks. pgmq v1.13.1 is a security release, and Supabase Queues is “built on the pgmq database extension.”

Retries and idempotency on SKIP LOCKED Postgres queues

All five claim work with SKIP LOCKED, so many workers share one queue without blocking each other. The pg-boss, graphile-worker, and Solid Queue docs say so, and the pgmq and River SQL on GitHub uses it.

And a job can run more than once. pg-boss says it plainly: “Jobs are delivered at least once,” so “Write handlers so that running one twice does no harm.”

That matters more for an agent than for an email job. Put a whole agent loop in one job, and a retry after a crash starts it from the top. You pay for the model calls again, and a tool that sent an email sends it again.

Three habits keep that safe:

  1. Small jobs. Run one model or tool call per job and keep the conversation in your own table. pg-boss flow() chains them, as do River Pro workflows.
  2. Keys on side effects. graphile-worker de-duplicates with a unique job_key. River unique jobs guarantee “only one exists for a given set of properties.” pg-boss policies such as singleton limit jobs per singletonKey.
  3. Transactional enqueue. In River, “A job inserted in a transaction becomes visible to workers only after the transaction commits.” So a saved message and the job that answers it can’t drift apart.

To make the whole loop durable on the same Postgres, see DBOS for AI agents. Retries and idempotency for agent tool calls covers the tool side.

Human approval on a Postgres queue: River Pro workflows and the two-job pattern

A job that waits for a person holds a worker slot the whole time, and a deploy stops it. So on four of the five queues, an approval is two jobs and a row:

  1. The first job runs the agent until it wants a risky tool, saves the pending call to your approvals table, and finishes.
  2. Your approve endpoint updates that row and enqueues the second job in the same transaction.
  3. The second job loads the conversation, runs the approved tool, and continues.

graphile-worker can add that second job “from a trigger or function” with graphile_worker.add_job, and pgmq.send is plain SQL inside your transaction. pg-boss takes your transaction through ORM adapters. Solid Queue uses a separate database by default, so set self.enqueue_after_transaction_commit = true in Rails 8 to enqueue after the approval commits.

River Pro workflows can wait instead. The docs list “Human approval or rejection” as a use for wait conditions, and this example from them runs a task once a reviewer approves or a 30-minute timer fires:

workflow.Add("decide_shipment", ShipmentDecisionArgs{OrderID: "ord_123"}, nil, &riverpro.WorkflowTaskOpts{
    Wait: &riverworkflow.WaitSpec{
        Expr: "manual_review_received || review_sla",
        Terms: []riverworkflow.WaitTermSpec{
            riverworkflow.WaitTermSignal(
                "manual_review_received",
                "manual_review",
                `payload.approved == true && payload.reviewer != ""`,
            ).Label("Manual review approved"),
            riverworkflow.WaitTermTimer(
                riverworkflow.TimerAfterWaitStarted("review_sla", 30*time.Minute),
            ).Label("Review SLA elapsed"),
        },
    },
})

Your approve endpoint emits the signal, with an idempotency key so a replayed webhook creates “only one signal row for the same logical event”:

_, err := workflow.Signals().Emit(ctx, "manual_review", ManualReviewSignal{
    Approved: true,
    Reviewer: "alice",
}, &riverpro.WorkflowSignalEmitOpts{
    IdempotencyKey: requestID,
})

Workflows are part of River Pro: $150 a month, or $125 a month billed yearly, for up to 20 developers.

On all five, the approval screen is yours to build. Human-in-the-loop approvals for AI agents compares the ways to build it.

Solid Queue and Rails 8.1 ActiveJob::Continuable for agent steps

Rails 8.1 (now 8.1.4.1) added Active Job Continuations, so a job can “continue from the last completed step rather than the beginning after a restart.” On Solid Queue, that’s the closest thing to durable agent steps without a workflow engine. Here’s the release notes example, adapted to an agent:

class SupportAgentJob < ApplicationJob
  include ActiveJob::Continuable

  def perform(ticket_id)
    # This always runs, even if the job is resumed.
    @ticket = Ticket.find(ticket_id)

    step :gather_context do
      @ticket.gather_context!
    end

    step :draft_reply do
      @ticket.draft_reply!
    end

    step :send_reply
  end

  def send_reply
    @ticket.send_reply!
  end
end

Four rules from the Active Job source decide how it behaves:

  1. Completed steps are skipped on resume, and a step in progress resumes “with the last recorded cursor.”
  2. Code outside a step runs on every attempt, so a model call there can run twice.
  3. Steps don’t save results. “Steps store serialized progress but they do not persist any other state,” so draft_reply! should save the draft to your database.
  4. Checkpoints ask the adapter whether to stop. A checkpoint calls queue_adapter.stopping?, and Solid Queue’s adapter sets that flag when its worker stops. The job then retries with its progress saved.

The release notes say why: Kamal gives “job-running containers thirty seconds to shut down by default.” A long model call isn’t a checkpoint, so give each one its own step. Durable AI agents in Rails compares the other Rails options.

Running agent jobs on the Postgres you already have

A queue runs your code reliably. For an agent, that code is still most of the work:

  1. The loop. Call the model, run the tools it asks for, append the results, and decide when it’s done.
  2. The stream. A job runs in a worker, not in the web request, so tokens reach the browser through a channel you add, such as LISTEN and NOTIFY or an SSE endpoint.
  3. The approvals. The pending-call table, the second job or the River Pro signal, and the screen.
  4. The context window. Long conversations need trimming to fit the model.

The other option is to keep the queue and move the loop out. With Cadenya hosting the loop, a pg-boss job just starts an objective. Create objective “rejects a duplicate externalId with AlreadyExists,” so a retried job finds the objective it already started:

import { PgBoss } from 'pg-boss'
import Cadenya from '@cadenya/cadenya'

const boss = new PgBoss(process.env.DATABASE_URL)
const cadenya = new Cadenya() // reads CADENYA_API_KEY and CADENYA_WORKSPACE_ID

boss.on('error', console.error)
await boss.start()
await boss.createQueue('start-agent', { retryLimit: 5, retryDelay: 60, retryBackoff: true })

await boss.work('start-agent', async ([job]) => {
  const externalId = `ticket-${job.data.ticketId}`
  try {
    await cadenya.objectives.create({
      agentId: 'external_id:support-agent',
      metadata: { externalId },
      firstUserMessage: job.data.question,
    })
  } catch (err) {
    // A retry after a successful create gets AlreadyExists. Retrieving by the
    // External ID confirms the objective exists; any other error throws here,
    // and pg-boss retries the job.
    await cadenya.objectives.retrieve(externalId)
  }
})

Events come back as signed webhooks. A handler can enqueue a job on objective_event.tool_approval_requested to notify a reviewer, keyed on the webhook-id header. The same shape works with River’s InsertTx, graphile-worker’s addJob, or a Solid Queue job.

What does Cadenya add to a Postgres job queue?

Cadenya is the agent loop, hosted, with approvals, conversation state, resume, and model swap, so your queue just starts objectives and handles webhooks. Here’s what that covers:

  1. Short jobs that are safe to retry. A job makes one API call, and an External ID prevents duplicate objectives for a record in your app.
  2. The agent loop, already written. Cadenya calls the model, runs the tools, records every event in a durable event log, and compacts the context window.
  3. Approvals without a second job. Mark a tool as needing approval, and Cadenya “parks the Agent loop until it receives approval or a denial with optional steering.” A denial carries a memo the agent reads, such as “Use the read-only lookup tool instead.”
  4. Conversation state and resume. A Continue message resumes a waiting objective with its conversation intact, and the event stream resumes from the last event ID.
  5. Webhooks your queue can consume. Each event arrives as a Standard Webhooks delivery with your External ID in the envelope, so a handler routes it without another API call.
  6. Schedules without a crontab. An agent schedule starts objectives on calendar or interval rules in your time zone.
  7. Model swap with no deploy. The model is a setting on an agent variation, on your own provider keys.
  8. SDKs and a price in one line. SDKs for TypeScript, Python, Ruby, and Go are at 1.9.0 under Apache-2.0. Free covers 1,000 loops a month, and Growth is $49 a month for 50,000, then $0.0015 a loop.

Create an Objective with an External ID shows the call your job makes, and the free plan needs no card.

No account yet? A coding agent can create a temporary workspace with cadenya workspaces create --temporary, run its first objectives there, and hand you a link to claim it, as auth.md explains. To create an account, sign up at app.cadenya.com/signup, then copy your API key from the API keys page at app.cadenya.com/account/apiKeys.

Grow wherever AI goes next.

Start shipping agents that are equipped to evolve.

A pine bonsai overlooking a mountain lake