Scheduling agent sandboxes is the job Agent Substrate does not do. It multiplexes many actors onto a small pool of warm workers, which is packing. When the pool is full, resume calls fail, callers retry, and the retry that lands first wins the slot.
I wrote the argument in agent runtimes have an autoscaler, not a scheduler. This is the how-to I would build on top of the public API without waiting for the runtime to grow a conscience. For a coding-agent fleet or an RL rollout set, that order is the difference between a finished step and a starved one.
Why doesn’t Agent Substrate decide who runs next?
Density is the runtime’s job. I have run that part. Nine agents on two worker pods in the published lab, later 18 on the same two workers, reserved capacity about 4.5x lower than always-on pods. One actor per sandbox, always. Idle agents live as zstd snapshots in object storage. A request restores an actor onto a free worker, the turn runs, the actor checkpoints back out.
None of that picks a winner.
The WorkerPool contract I pulled from a live CRD on substrate v0.0.8 is four settings and a pod template: ateomImage, replicas, sandboxClass, sandboxConfigName, and template. ActorTemplate carries containers, pause image, sandbox class, snapshots config, volumes, and a worker selector. There is no field that says this agent matters more than that one.
The boundary behavior matches the CRD. Substrate does not queue when the pool is full. It rejects:
substrate worker pool has no free workers
So the queue is not absent. It lives in whatever retry logic the callers happen to have. The autoscaler I shipped in Substrate Scope measures busy + queued. A count. It knows how much work is waiting and knows nothing about whose work it is. That is fine while you can still add replicas. It stops being fine at a ceiling. CPU is the wrong signal to autoscale agents. Scaling answers a different question.
Ghost occupancy is a special case of “full.” A killed session can pin a worker while the pool looks idle. Reset first. Then argue about policy. Ghost actors pin your workers.
What would a resume queue actually add?
A queue the runtime does not have. Today the queue is in retry loops. Pull it into a component you own. Ordered by policy, not by who hammered /resume hardest. The incident-shaped version of this race is who runs next when the agent pool is full.
Preemption of idle actors. If an actor is live but waiting on a model, and a higher class needs a slot, park the idle one. You can only do this if suspend is cheap and suspend-safe networking is not required for that wait. Model waits: yes. Open DB transactions: no. Checkpoint-and-yield is conceivable here in a way it is not for a stateless pod, because Substrate already snapshots to object storage. Whether that is cheap enough to do under contention is an open question I have not measured. Do not write a preemption SLA you have not timed.
A free-worker buffer. Never run at 100% occupancy if restores are bursty. I already scale with a floor of 2 on a laptop pool. The Scope policy clamps busy + queued to [2, 8]. Production wants headroom you can express as a number, not a vibe. Size workers to simultaneous live sessions plus that buffer, not to registered agents. How many agents per Kubernetes pod.
Per-pool policy as a Kubernetes object. Classes, quotas, fair share. Teams reference a class. They do not invent priority: 10000. The PriorityClass plus ResourceQuota pattern is the one I trust, pointed at slots instead of pods. An admin defines the classes. A namespace gets a budget of the expensive class. The team still decides what matters to them. They cannot decide that everything does.
Worker pod placement can stay with whatever you already use to put pods on nodes. That layer is solved. Do not confuse it with actor admission.
Why is Kubernetes PriorityClass the wrong layer?
Grep the substrate CRDs for anything priority-shaped and you get priorityClassName on the WorkerPool pod template, plus weight on preferred node affinity. Both sit inside spec.template. ActorTemplate contributes nothing.
priorityClassName is real Kubernetes pod priority and preemption. It decides whether a worker pod gets a node, and it will evict other pods to make that happen. What it cannot do is decide which actor gets which worker slot, because at that layer every worker is identical and every actor is invisible. Kubernetes is scheduling the container that hosts the agents. Nobody is scheduling the agents.
Kueue already built the primitives one abstraction over: cluster-scoped WorkloadPriorityClass, ClusterQueue quota with borrowing across a Cohort, and preemption by classic or fair-sharing algorithms. Right shape, wrong granularity. Kueue admits a Workload that becomes pods, once, at admission. An agent runtime needs a per-session decision about which warm worker slot a restored actor lands in, on the timescale of a snapshot restore rather than a pod boot. Pointing Kueue at a WorkerPool buys you nothing at the slot layer.
API Priority and Fairness exists for the same reason at the apiserver: rate limiting by volume punishes everyone equally and protects nothing. The shape you want for actors is a flow with a share, pointed at worker slots and at the model budget. The model budget is often the genuinely scarce resource, and it is represented nowhere in the WorkerPool.
What policies would I ship first?
Start with a QoS split, not a ranking of every agent.
- Interactive floor. On-call and human-in-the-loop get a reserved number of slots. They cannot take the whole pool. An incident-response agent does not need to be “more important” than a nightly enrichment job. It needs a bounded time to first token. Give it a floor it does not share.
- Batch cap. A2A and training share the remainder with fair share so one loop cannot empty the buffer. The enrichment job wants to finish before morning. It does not care whether that is 2am or 5am.
- Aging or fair share. If you only serve the high class, the low class never runs. I would rather copy Kueue’s fair share than invent aging badly, but I would pick one counterweight on purpose. Strict priority without that term is a starvation generator.
That dissolves most of the arbiter problem. Two classes that are not competing for the same guarantee do not need a central ranking. What it does not dissolve is two genuinely latency-sensitive workloads wanting the same floor at the same moment. That case is small, real, and the only place an arbiter is actually required.
RL-specific notes are in scheduling sandboxes for RL. For training I would start with fair share across rollouts in the step, not “interactive beats batch,” because here the rollouts are the job. A biased subset of rollouts is a biased gradient.
Do not attach the class to the Agent object and call it done. Criticality is a property of the request, not of the agent. The same SRE agent answering “what version is in staging” and driving a sev1 is one object with one label. Attach priority to the agent and the class is wrong most of the time. Attach it to the request and the caller inflates it. I do not know which is less bad. I do know a free-text field on every SandboxAgent is how everything becomes critical.
What should I refuse to build?
Put a priority field on every Agent object and let teams fill it in. Everything becomes critical. I made this mistake in my head before I remembered ResourceQuota can bind a PriorityClass. Quota is what makes a class expensive.
Scale out of contention forever. GPU, rate limits, and replica ceilings exist. Autoscaling is the wrong complete answer. The night extra workers made a serial generator worse is the same lesson from the other side. The autoscaler made it worse.
Jittered retries as fairness. Jitter only changes who wins the race. It does not encode that the pager matters more than the enrichment job.
A dashboard of pod CPU as proof the pool is fine. Watch the workers list. kubectl is lying to you. Occupancy of live slots is not a queue of who is waiting.
Checklist: ship a slot policy without waiting on the runtime
- Count
substrate worker pool has no free workersat every caller, not only at ateapi. - Keep a free-worker buffer. Floor of 2 on a tiny pool. Express the production buffer as a replica count, not a feeling.
- Split interactive and batch onto two WorkerPools if you need an answer this week. No new CRD.
- If they must share, put a proxy in front of resume with a FIFO per class and a reserved floor for interactive.
- Fail closed on ghost occupancy: a worker assigned longer than your longest plausible session, with no turn activity, gets flagged, then reset.
- Do not point pod PriorityClass, Kueue, or a CPU HPA at this problem and stop. Those tools answer a different layer.
- Write down which class may starve which, on purpose. If you cannot name it, you have a race.
The published lab and the CRD notes are in kagent Agent Substrate. Field guide: Agent Substrate.