Queue examples
Runnable file: agentium-examples/queue/07-background-job.ts. Guide: Queue Needs Redis onlocalhost:6379.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Enqueue an agent run. A worker on Redis picks it up.
localhost:6379.
npm install @agentium/queue
import { Agent, openai } from "@agentium/core";
import { AgentQueue, AgentWorker } from "@agentium/queue";
const reportAgent = new Agent({
name: "report-gen",
model: openai("gpt-4o"),
instructions: "You write short reports with headings.",
});
const queue = new AgentQueue({
connection: { host: "localhost", port: 6379 },
});
const { jobId } = await queue.enqueueAgentRun({
agentName: "report-gen",
input: "Q4 engineering report.",
priority: 1,
attempts: 3,
});
const worker = new AgentWorker({
connection: { host: "localhost", port: 6379 },
concurrency: 3,
agentRegistry: { "report-gen": reportAgent },
});
worker.start();
queue.onCompleted((id, result) => {
console.log(id, result.text.slice(0, 200));
});