Expand description
The task queue: what magi should do next, and who asked for it.
The queue is what lets magi run unattended. magi serve takes the next
task, runs the graph on it, records the outcome, and takes the next one.
It is also the reason an agent can ask for work. magi task add is the
whole interface, and it is the same command whether a human types it at a
prompt, a phone posts it through the web UI, or an implementer inside a run
shells out to it because it noticed something worth doing but out of scope.
magi’s CLI is the operating surface for both kinds of user; the queue is
where their intentions meet.
One task is one JSON file under Queue’s root. Files rather than a
database because the operator has to be able to read, edit, and delete the
backlog with the tools already on the machine, and because a crashed daemon
must leave a queue the next one can pick up without recovery ceremony.
§Shape
Task is data plus pure state transitions - Task::fail decides
whether an attempt was the last one, and touches no disk. Queue owns all
I/O and is constructed with its root, so a test drives a real queue in a
temp directory without setting a process-global home. Splitting them this
way is why the retry policy below can be asserted directly.
§Bounded by construction
An autonomous loop that retries forever is a way to spend money on a task
that cannot succeed. Every claim increments Task::attempts; a task that
has burned its attempts becomes TaskStatus::Held and waits for a human
rather than for another agent.
Structs§
- Answered
Question - One question
crate::conductasked about a task, and what the operator said back. SeeTask::answers. - Claim
- Exclusive ownership of a task, released on drop.
- Queue
- A queue on disk.
- Task
- One unit of work.
Enums§
- Hold
Source - Who placed the current hold.
- Source
- Where a task came from. Recorded because “who asked for this” is the first question about an autonomous run, and the answer is not recoverable later.
- Task
Status - Where a task is in its life.
Constants§
- SCHEMA
- On-disk format for a queued task. Bumped when a field’s meaning changes.
Functions§
- title_
from - The first line of a task, trimmed to a title. Used when the caller gives a body but no title, which is the normal case for an agent piping a file in.