Skip to content

Scheduling and runs

A run is one prompt and everything the agent does with it, on a hosted thread. This page covers runs that go on without a client watching: in the background, on a schedule, or started by another system. All of it needs hosted threads (THREADS and FELIX_API_TOKEN) and the RUNS Durable Object binding; /health reports runs: true where both are there. See Deploy.

With RUNS, a thread’s runs execute in a Durable Object of their own (one per thread), not in the request that started them. Closing the stream detaches the client and the run carries on; it ends only when it finishes, fails, reaches its step limit or is stopped. A second prompt while one is going is refused with 409 run_in_progress. Without RUNS, closing the stream cancels the run and leaves the thread interrupted.

Rejoining. Each event a background run streams carries an SSE id, <run>.<seq>. GET /v1/threads/<id>/events?after=<position> (or the Last-Event-ID header) streams the thread’s latest run from after that position, then its live events until it ends. The run’s events are kept in memory until the thread’s next run starts; text streamed before a committed message is dropped from them, since the message carries it. 404 no_run means there is nothing to rejoin: no run has started on that host, or it was restarted. Read the thread instead.

The web app does this for you: leaving a conversation marks its reply Still running on the server, and opening it again picks the reply up where it is. See Web surface.

Stopping. POST /v1/threads/<id>/stop answers { stopped }. The run’s streams end with error run_stopped, the thread is left interrupted, and the thread’s sandbox, if it has one, stops with it. A steer (POST /v1/threads/<id>/steer) changes a running run’s course without stopping it; see Steering.

The thread’s owner, an admin and the operator token may rejoin, stop and schedule a thread’s runs; anyone else gets 404 thread_not_found.

With FELIX_RUN_SOCKET=on, a client that keeps a connection open can use one WebSocket per thread instead of a request per action: GET /v1/threads/<id>/socket, with the bearer token. A browser, which cannot send one on a WebSocket, first asks POST /v1/threads/<id>/socket/ticket for a ticket and opens …/socket?ticket=<ticket> within a minute; a ticket opens one socket.

Each frame is one JSON object. The client sends:

Message Does
{ "type": "send", "prompt": "…", "revision"?: n } Sends a prompt, at the thread’s current revision unless one is given, and follows the run it starts.
{ "type": "steer", "text": "…" } Steers the running run.
{ "type": "stop" } Stops it.
{ "type": "decide", "approval_id": "…", "decision": "approved" | "denied", "note"?, "edited_args"? } Decides a call waiting on an approval.
{ "type": "follow", "after"?: "<position>" } Follows the thread’s latest run, from after position.
{ "type": "ping" } Answered with pong.

Any of them may carry an id, which the answer repeats. The server sends { "type": "event", "event", "position" } for each event of the run it follows (the run stream’s events), run_ended when that run’s stream ends, idle when there is no run to follow, ok (with for and a result) and error (with a code and the HTTP status when a route refused). On opening, the socket follows the latest run, from after ?after=<position> when given.

Every action is the same request the HTTP routes take, checked again each time with the credentials the socket was opened with, so a session that is revoked or expires stops working on an open socket. A run another client starts is not announced; send follow to pick it up, or watch the thread’s change feed. Closing the socket leaves the run going. Each socket opened is audited as run_socket_opened.

Wherever RUNS is bound, each hosted thread also has a change feed: a WebSocket that says when the thread changes, whoever changed it, whether that’s another browser, the terminal, a schedule or a person renaming it. The web app keeps one open for the conversation on screen, so a reply sent from elsewhere, a run started elsewhere, a rename or a delete shows up without reloading. Set FELIX_THREAD_FEED=off to turn it off; the web app then offers Reload from server instead.

Open it with GET /v1/threads/<id>/feed and the bearer token, or, from a browser, ask POST /v1/threads/<id>/feed/ticket for a ticket and open …/feed?ticket=<ticket> within a minute. The server sends, one JSON object per frame:

Message Means
{ "type": "thread", "thread": { … } } The thread’s summary as it stands: on opening, and after each change. Changes close together arrive as one. Read the thread again when its revision is newer than yours.
{ "type": "deleted" } The thread was deleted. The connection then closes with code 4004; don’t reopen it.

The client sends nothing but an optional ping, answered pong. A connection is served for at most 15 minutes and then closed with code 4000: open a new one with a new ticket, which checks the person’s access again, so someone whose access ends stops hearing about the thread.

The thread list has a feed too: GET /v1/thread-feed, with a ticket from POST /v1/thread-feed/ticket. It sends { "type": "changed" } when the list you can see may have changed (one of your threads, or any thread for an admin, made, changed, run or deleted anywhere), at most about once a second, and once on opening; read GET /v1/threads again when it does. The web app’s sidebar uses it, so a conversation started in the terminal is listed at once. Its lifetime and close codes are the thread feed’s.

A schedule sends a prompt to one thread at a time you choose, and can repeat: every so many minutes, or whenever a cron expression matches in a time zone. The web app calls them jobs, on the Jobs page (Manage → Jobs); see Jobs.

Route Does
GET /v1/threads/<id>/schedules { schedules }, soonest first: each { id, name?, prompt, nextAt, everyMinutes?, cron?, timezone?, createdAt, byAgent?, paused?, lastRunAt?, lastOutcome?, lastError? }, times in epoch milliseconds.
POST /v1/threads/<id>/schedules { name?, prompt, paused?, at?, everyMinutes? } or { name?, prompt, paused?, cron, timezone? }: 201 with the schedule.
PATCH /v1/threads/<id>/schedules/<scheduleId> Change name, prompt, at, everyMinutes, cron or timezone: the schedule as it now is.
POST /v1/threads/<id>/schedules/<scheduleId>/pause · /resume · /run Pause it, resume it, or send its prompt now (202 { started, schedule? }).
DELETE /v1/threads/<id>/schedules/<scheduleId> Remove one; 404 schedule_not_found.
  • Name. name is an optional label, up to 80 characters, that the Jobs page shows in place of the prompt. Names need not be unique; the schedule’s id is what every route acts on. A PATCH with name: "" removes it.
  • Starting paused. paused: true on create stores the schedule paused: it sends nothing until resumed, and Run now still sends it.
  • When. at is the first run, in epoch milliseconds, up to a year ahead. everyMinutes repeats it, 5 to 10080 (a week). Give either or both; with only everyMinutes, the first run is one interval from now. A one-time schedule removes itself once it has run. A cron schedule takes neither: see Cron schedules.
  • From a conversation. The agent can schedule follow-up work with schedule_task, and list and cancel it. A person approves each task first, seeing its prompt and when it runs. A task an agent made has byAgent: true; editing it makes it yours, and the agent can no longer cancel it. Runs nobody is in (a schedule’s, a trigger’s, a workflow step’s) cannot schedule more work.
  • Limits. At most 10 per thread (429 schedule_limit). A prompt is 1 to 32,768 characters. 400 invalid_schedule for a body that does not fit (a cron that does not parse or never fires included), 400 invalid_schedule_time for a first run more than a minute in the past or more than a year ahead, 400 schedule_too_frequent for a cron whose runs fall under 5 minutes apart.
  • Running. The thread’s run host wakes on a Durable Object alarm and sends the prompt to the thread as it is then, as the thread’s agent, with the thread owner’s connections and memories. The run acts as the thread’s owner, with their role, as a run they started would: their approvals and image grants apply, and nothing reserved for admins opens to a member’s schedule. A thread the operator made runs as the operator. A tool call that needs approval waits for a person, as in any run.
  • An owner who can no longer sign in. If the owner’s account was deleted, their sessions were revoked and they have not signed in since, or the sign-in settings no longer give them the role they signed in with, a due schedule does not run: it is paused, its last outcome failed with the reason. Run now answers 403 owner_not_allowed. Resume it once the owner can sign in again.
  • A busy thread. If a run holds the thread when a schedule is due, it tries again a minute later. A repeating schedule does not make up runs it missed, whether the thread was busy, the host was away or the schedule was paused: it moves on to its next time from now.
  • Editing. PATCH changes only the fields it is given. cron makes a schedule a cron one (dropping its interval); at or everyMinutes makes it a time-and-interval one (dropping its cron and zone); timezone alone moves a cron schedule to another zone. A change to when it runs works nextAt out again from now; a prompt-only change keeps it. A paused schedule stays paused.
  • Pause, resume, run now. A paused schedule sends nothing until resumed. Resuming one whose time passed moves it to its next time from now; a one-time schedule whose time passed runs at once. Run now sends the prompt at once, paused or not; it uses up a one-time schedule.
  • Audit. Edits are audited as schedule_updated with the schedule id and the names of the fields changed, never their values; pause, resume and run now as schedule_paused, schedule_resumed and schedule_run.
  • Deleted threads. A thread’s schedules are dropped the next time one is due after the thread is deleted.

{ prompt, cron, timezone } runs the prompt whenever cron matches on the wall clock of timezone, an IANA zone name such as America/New_York or Europe/London (UTC when left out). The schedule keeps the zone in its canonical spelling, and its nextAt is the next match, worked out again after each run, on resume, after Run now and after an edit.

cron is standard five-field cron, minute hour day-of-month month day-of-week:

Field Values
minute 0–59
hour 0–23
day of month 1–31
month 1–12
day of week 0–7; 0 and 7 are Sunday

Each field is *, a number N, a range A-B, any of those with a step (*/15, 9-17/2; 5/15 means “from 5, every 15”), or a comma list of them (0,30). Numbers only: month and weekday names, L, W, #, ? and a seconds field are refused. The aliases @hourly, @daily (@midnight), @weekly, @monthly and @yearly (@annually) stand for 0 * * * *, 0 0 * * *, 0 0 * * 0, 0 0 1 * * and 0 0 1 1 *; they are kept as written. @reboot and @every are refused (an interval is everyMinutes).

  • Both day fields. When day of month and day of week are both restricted, a day matching either one fires, as in classic cron: 0 9 1 * 1 is the 1st of each month and every Monday. A day field starting with * (*/2 included) counts as unrestricted, so 0 0 */2 * 1 is odd days that are Mondays.
  • Daylight saving. A cron fires once per matching local time. A time the clocks skip fires at the first instant after the gap: 30 2 * * * in New York runs at 03:00 EDT on the spring change. A time the clocks repeat fires at its first occurrence only: 30 1 * * * runs once on the autumn change, at 01:30 EDT. So @daily runs once every local day, and 0 * * * * runs 23 times on the spring day and 24 on the autumn one.
  • Never fires. An expression with no matching minute in the next nine years (enough to reach the next 29 February across a skipped leap century), such as 0 0 30 2 *, is refused.
  • Five minutes apart. As with everyMinutes, runs must be at least 5 minutes apart, so * * * * * and 0,3 * * * * are refused. The check walks the next 200 runs and every run around the zone’s clock changes in the next year, where a skipped hour can bring two runs closer: 3,30 2,3 * * * is fine in UTC and refused in New York.
  • Length. At most 100 characters.
curl -X POST "https://felix.example.com/v1/threads/$THREAD/schedules" \
-H "authorization: Bearer $FELIX_API_TOKEN" -H 'content-type: application/json' \
--data '{"prompt":"Post the stand-up summary.","cron":"0 9 * * 1-5","timezone":"America/New_York"}'

Other times are absolute instants. The deployment’s time zone (FELIX_TIMEZONE, UTC by default) is the one the model is told and the time tools assume; it does not move a schedule. The Jobs page shows and takes times in your browser’s zone, and a cron job’s next runs in its own zone.

POST /v1/threads/<id>/trigger lets another system start a run on a thread, now, without the API token: the request proves itself with a signature instead. It needs RUNS and FELIX_SIGNING_SECRET; without the secret it answers 503 triggers_not_configured.

The body is { prompt }. Sign it with HMAC-SHA256, keyed by the signing secret, over <timestamp>.<body> exactly as sent, and send two headers:

Header Value
felix-timestamp Unix seconds. More than five minutes from the server’s clock is refused.
felix-signature sha256=<hex digest>
body='{"prompt":"Summarize the alerts since yesterday."}'
ts=$(date +%s)
sig=$(printf '%s.%s' "$ts" "$body" | openssl dgst -sha256 -hmac "$FELIX_SIGNING_SECRET" | sed 's/^.* //')
curl -X POST "https://felix.example.com/v1/threads/$THREAD/trigger" \
-H 'content-type: application/json' \
-H "felix-timestamp: $ts" -H "felix-signature: sha256=$sig" \
--data "$body"
Answer Means
202 { started: true } The run started.
401 bad_signature The signature does not match, or the timestamp is stale.
409 trigger_replayed That signature was already accepted, on this thread or any other.
409 run_in_progress A run holds the thread.
403 owner_not_allowed The thread’s owner can no longer sign in.
404 thread_not_found No such thread.
503 storage_unavailable The deployment could not check the signature against those it has accepted; send it again with a fresh timestamp and signature.

Each signature is accepted once across the deployment and starts at most one run: the same signed request sent again, to this thread or another, is refused. It counts as used once it is accepted, even when the thread was busy, so a retry needs a fresh timestamp and signature. The run is like a scheduled one: the thread’s agent, acting as its owner, with their connections. Anyone who holds the signing secret can start a run on any thread of the deployment, so keep it to the systems that need it.

With FELIX_WEBHOOK_URL and FELIX_SIGNING_SECRET set, a run started by a schedule or a trigger posts this to that URL when it ends:

{
"event": "run.finished",
"threadId": "…",
"source": "schedule",
"scheduleId": "…",
"outcome": "complete",
"at": 1767225600000
}

source is schedule or trigger (scheduleId only for a schedule), and outcome is complete, limit, failed or stopped. The request is signed the same way as a trigger, with felix-timestamp and felix-signature, so a receiver checks it with the same secret. It carries no message text: read the thread for what the run said.

Delivery is one attempt with a 10-second timeout, and is not retried. Runs a person or client starts post nothing. The URL is the operator’s setting alone; no request can name another.

A workflow is a graph of steps (agent turns, tool calls, approvals and branches) that runs durably on the deployment’s Workflows binding: a run carries on through restarts and can wait days for a person. Workflows are started from the Workflows page or POST /v1/workflows/<id>/runs; a schedule or trigger cannot start one. See Workflows.

Every hosted run is recorded on its thread when it starts and when it ends. GET /v1/threads/<id>/runs?cursor=&limit= lists them newest first (limit 1 to 100, 20 by default), each with when it started and ended, its outcome, model and agent, model turns, input and output tokens, and every tool call’s name, error, whether it was blocked, and execution duration (up to 200 per run). When Stop interrupts a batch, a saved cancellation result marks the call as an error if its tool started, or blocked if it never began execution. Tool timing ends when the call returns or throws, even if a progress update is still being delivered. A record with no end belongs to a run that stopped without saying so, such as one a deploy ended. The newest 100 runs per thread are kept, and deleting the thread deletes them.

The Activity page (Manage → Activity) reads these records for the threads that ran in the last day, week or month, counts those that failed, and links each to its conversation; scheduled and triggered runs appear there like any other. See Activity. Where the deployment stores traces, each run there also has its trace; see Traces.

The terminal client keeps its own run history for local runs; see Run history.