Worker lifecycle · 3 min read
What Should an AI Worker Check Before It Starts?
One missing acceptance criterion can make an otherwise healthy worker a poor scheduling choice.
A scheduler finds an idle GPU worker and assigns it task 142. The repository opens. The right model is loaded. The ticket asks the worker to “improve the parser,” and the acceptance field is empty. The worker can spend the afternoon producing perfectly reasonable edits. At review time nobody can tell it which change would finish the ticket.
A preflight is a cheap opportunity to catch that situation while the task is still in the queue. I would run it on the machine and worktree about to receive the assignment. A healthy coordinator cannot establish that another machine has the right model loaded, that its checkout is isolated, or that its test command exists.
Ask the runtime for the facts it owns
Lemonade’s structured status and health interfaces are useful starting points. Run the checks against the intended service. Record the backend and active model, then compare them with the assignment’s requirements. For a task with a large input, inspect the served context limit as well. A response from a health endpoint establishes reachability at that moment. Model identity and capacity need their own observations.
lemonade status --json
curl -s http://localhost:13305/api/v1/health
A backend launch command can help an operator reproduce a configuration mismatch. Keep the command associated with the particular worker and runtime revision that produced it. Replacing a missing local observation with yesterday’s successful run makes the scheduler overconfident about a machine whose state may have changed since then.
Print the reason the worker is waiting
$ worker preflight --task 142
OK repository accessible
OK worktree isolated
OK backend reachable
OK requested model loaded
OK context budget available
OK validation tools available
MISSING acceptance criteria
BLOCKED task not started
This transcript illustrates a proposed worker interface. The missing row has an owner. The requester can turn “improve the parser” into “accept blank lines between records and retain the existing rejection of malformed dates.” A fixture for each behavior makes the change visible. Restart preflight after the ticket changes, so the run record captures the assignment the worker actually received.
The checks have different lifetimes. A commit identifier can stay useful for as long as the worktree points to it. Free capacity can change between scheduling and generation. Acquire or recheck scarce resources at dispatch. A preflight that says a tool is installed still needs a later execution result showing whether that tool passed. The worker’s readiness receipt and its final acceptance receipt answer different operational questions.
Try removing one prerequisite
To evaluate a Fredrin-style scheduler, prepare a known-good fixture assignment and make one dependency unavailable at a time. Remove the validator, request a different loaded model, or clear the acceptance field. For each run, expect a named cause and an owner who can resolve it. Count whether generation was ever scheduled. When the missing item is restored, run the full preflight again and check that exactly one assignment is dispatched.
That experiment gives a team a concrete way to decide whether another check is worth adding. Measure the cost of running the check and the cost of discovering the same condition at review time. A quick check for an empty acceptance field might save an entire round of implementation while giving the requester a much better question to answer.
Supporting diagrams (4)
