Owner-scoped scheduler jobs
Advanced index · Runnable routes · Focused test · Authoritative contract
Use Core's scheduler for recurring agent work; do not build a private recurring setInterval loop in a mod host.
const job = await context.scheduler.create({
agentId: 'hatchet',
name: 'Morning lesson',
prompt: 'Prepare today’s lesson.',
cron: '0 8 * * *',
enabled: false,
// Optional pair: modelConnectionId, model
});
Core binds ownerModId from the installed host. A mod cannot choose the owner or job ID. Every list, read, update, delete, runs, and trigger is owner-scoped; a foreign job is indistinguishable from a missing one. This is installation ownership, not per-user authorization—your routes must still enforce product access.
Jobs are disabled by default. Prefer create-disabled, show the operator the exact agent/prompt/schedule, then explicitly enable. All jobs use the operator timezone; legacy timezone payload fields are ignored. modelConnectionId and model must be supplied together. On update, set both to null to clear an override; Core uses the same selected-model validation as operator jobs.
Current Core job kinds versus the Tutor adapter
The current Core store also supports jobKind: "task" with taskId and optional extraInstructions, and scheduleKind: "once" with runAt; omitted kinds retain prompt/cron behavior. The owner-scoped capability forwards to that store while retaining installed-mod ownership. Task targets must be existing ToDo tasks assigned to the selected agent. Do not treat this as permission to bypass product authorization or task eligibility.
Tutor’s bundled create/update adapters deliberately accept only the prompt/cron fields shown in this lesson. They do not accept task IDs, one-time scheduling fields, or contextMode; adding those fields to a Tutor HTTP request is rejected. Adapting the lab requires runtime changes and corresponding negative tests, not just a documentation example. See Core’s scheduled-work guide for operator behavior and one-time consumption semantics.
Read, page, update, and trigger
let cursor;
do {
const page = await context.scheduler.list({
limit: 100, enabled: true, ...(cursor ? { cursor } : {}),
});
consume(page.jobs);
cursor = page.hasMore ? page.nextCursor : null;
} while (cursor);
const current = await context.scheduler.read(job.id);
const changed = await context.scheduler.update(job.id, { enabled: true });
const receipt = await context.scheduler.trigger(job.id);
let runCursor;
do {
const page = await context.scheduler.runs(job.id, {
limit: 100, ...(runCursor ? { cursor: runCursor } : {}),
});
consumeRuns(page.runs);
runCursor = page.hasMore ? page.nextCursor : null;
} while (runCursor);
Lists default to 50 and cap at 100, with a separate 240,000-byte serialized JSON page budget. A page can therefore contain fewer records than the requested limit. Run-history entries that cannot fit individually are projected to metadata with result: { truncated: true, reason: "scheduled_job_run_output_limit" }; this is not the full execution result. Cursors are opaque; repeat the same filter and follow nextCursor only while hasMore is true. Scheduler pages are not documented as immutable snapshots, so consumers that need durable export must tolerate live changes and deduplicate stable IDs.
Manual trigger uses the shared scheduler. A 202-style Tutor route response means accepted/receipted, not that an agent run succeeded. Inspect run history later. Delete responses should likewise be treated according to Core's returned record, not as proof that previously dispatched work was undone.
Tutor supplies operator-only JSON routes for all seven operations:
GET/POST /advanced/scheduler/jobsGET/PATCH/DELETE /advanced/scheduler/jobs/:jobIdGET /advanced/scheduler/jobs/:jobId/runsPOST /advanced/scheduler/jobs/:jobId/trigger
Use the scoped UI api helper, so these paths remain beneath /api/mods/burrow-reference-mod.
Validate against the real store
Core's persistent scheduler also validates cron syntax, limits prompts to 20,000 characters, and restricts session IDs to 1–96 letters, digits, dots, underscores, or hyphens. Tutor's adapter has looser length checks (100,000 for prompts and 128 for session IDs). Values between those limits, invalid cron, or invalid session-ID characters can pass the example adapter but fail in Core; the example maps that unexpected rejection to 500 advanced_request_failed.
Keep inputs within Core's limits and add store-backed negative tests when adapting this example. The lightweight integration scheduler fixture does not establish production PostgreSQL validation behavior.
Lifecycle, recovery, and failure
enabled is durable scheduling intent, not evidence that the owner is running. A mod-owned job dispatches only while that exact mod is loaded and healthy. Disabled, crashed/failed, uninstalled, undiscovered, or not-yet-loaded owners are ineligible; schedules remain pending. Normal claiming resumes when the owner loads again. Manual trigger enforces ownership and current owner availability.
A route timeout, host reload, or failed response is not proof that a create/update/trigger had no effect. Read/list by the identifiers you retained before blindly retrying mutations. The ordinary scheduler API does not advertise idempotency keys or per-call cancellation. Design product-level duplicate prevention where repeated submissions matter.
Do not place secrets in job names/prompts unless the scheduler/agent workflow is explicitly designed to hold them. Capability errors reject; Tutor maps unexpected failures to advanced_request_failed rather than leaking internals.
Boundary
Owner scoping cannot be overridden by body fields, tool arguments, installation, or MCP grants. Operator-owned jobs (ownerModId: null) and another mod's jobs are outside this facade. context.modManagement is a separate privileged capability and is neither required nor granted here.
Verify
test/advanced-capabilities.test.mjs verifies owner fields are not accepted, jobs default disabled, model selectors are paired, and trigger returns promptly. Archive UI tests exercise a list consumer. npm run test:core executes create/list/read/update/run-history/trigger/delete through Tutor's forked host and current Core owner-scoped scheduler capability using controlled durable-store semantics. Foreign-owner isolation, cursor limits, selected-model rejection, operator-timezone inheritance during dispatch, and unavailable-owner behavior remain focused gaps. See coverage.
Current Core restart receipts
Checked 7 November 2026: Core can reconcile an interrupted scheduled run from its exact staged terminal result, matching task result, or committed chat continuity plus matching terminal receipt and assistant turn. It does not rerun the prompt to reconstruct an answer. Missing evidence leaves a missed run; a receipt-write failure is separate from execution failure. Invalid/unresolvable schedules are disabled with a failed schedule receipt so valid jobs can continue. These are current Core contracts, not new Tutor adapter fields or newly executed Tutor tests.
Native tools are a separate pagination contract
Checked 12 November 2026: Core’s native agent scheduler tools now use scoped opaque cursors and explicit page counts. The mod-owned scheduler facade taught here remains separate, including its existing limit of 100; do not pass native cursor fields to this lab or infer that it exposes new routes.