Tasks
Save a job for an agent to run in the background, then start it on demand or on a schedule.
Save a job once and let your agent run it whenever you need, with no user waiting. A task holds the agent, the instruction, and optionally a schedule. Each time it runs, you get a separate task run with its own status and transcript.
Create a task
Set AGENT_ID to an agent with a provider and model, such as the one from the quickstart.
import { BlazingAgents } from "@blazingagents/sdk";
const client = new BlazingAgents({
apiKey: process.env.BLAZING_AGENTS_API_KEY!,
});
const { task } = await client.tasks.create({
agentId: process.env.AGENT_ID!,
name: "Weekly report",
prompt: "Build the weekly report and summarize the result.",
userId: "app:user-42",
});
console.log(task.id, task.schedule);You see tk_... null (None in Python). With no schedule, the task runs only when you start a run. Add a schedule to run it on a clock instead.
What a task controls
- Agent and instruction. Every run sends the same
promptto the same agent. - Version. By default each run uses the agent's latest configuration at the moment the run is queued. Set
agentVersionto pin a known-good version instead. - Schedule and enabled state. A schedule starts runs automatically. Setting
enabled: falsepauses scheduled runs, but you can still start a run yourself. - User label. The task's
userIdandmetadatacarry over to every run, its session, its usage, and its artifacts. See tenancy and attribution.
The task also shows its current active run and latest run, so you can see what is happening without listing every run. For every field and default, see tasks.create().
Tool approvals in tasks
No one is present to approve a tool call during a task. Tasks follow the agent's approvalInTasks policy. A tool call that would need a person is denied, and the agent is told so it can continue with other work. If a run still ends up waiting for a person, it fails. See tool approvals.
Change or delete a task
Changes apply to future runs only. A run that is already queued or running keeps the version and settings it started with. The agentId and userId cannot change after creation.
Deleting a task removes it and its schedule. It does not undo anything earlier runs did, such as files written or messages sent. Cancel an active run first if you need it stopped.
Production notes
- Creating a task with
submit: truealso starts a run, but that path has no idempotency key, so a retry creates a second task and run. When duplicates matter, create the task first, then start runs with an idempotency key. - Your API key can reach every task in your account. Check in your backend that the current user may read, change, or run a task before you pass its ID.