The Autoscaler Made It Worse

Part of: Agent Runtimes

The autoscaler made it worse on a serial model backend: adding Agent Substrate workers moved the queue downstream and made every turn slower.

The autoscaler made it worse. On a model backend that generates one response at a time, adding Agent Substrate workers does not add throughput: it restores more actors, holds more slots, and moves the wait onto the same serial generation queue. Per-turn latency climbs while the board still looks like you scaled the right thing.

Lesson three from the talk. This is the one where I did everything right and still lost.

Why did adding agent workers make latency worse?

The lab started on a local model through Ollama. Load came in, the pool filled, rejections showed up, and the autoscaler from CPU is the wrong signal to autoscale agents did its job and added workers.

Things got slower.

The model backend was generating one response at a time. More workers did not mean more work getting done. It meant more agents restored, holding slots, all waiting in line at the same single generation queue. The queue moved from my callers’ retry loops to the model, where the board could not see it, and every turn took longer.

That is a different lie than kubectl is lying to you. The workers list was honest. Slots were busy. Occupancy was high. Rejections had been real. CPU was still the wrong scale signal, and I had not used it. I had used busy + queued, which is the right count for slots, and the wrong count for tokens.

What is Agent Substrate: one actor per worker, snapshots in object storage, a small pool of pre-warmed sandboxes. Simultaneous sessions equal worker count. That sentence is true and incomplete. Simultaneous model generations equal whatever the backend will run at once. If that number is one, the second, third, and eighth restored actor are not serving anyone. They are holding a bay in a line you cannot see on the board.

The laptop numbers still hold. Eighteen agents on two workers for the talk setup, nine on two in the first lab, over a thousand real sessions, reserved capacity about 4.5x lower than always-on pods. Density is about reservation. Throughput is about the slowest serial step. I had optimized the first and then scaled as if I had the second.

Why is that not the autoscaler’s fault?

The autoscaler only knew about slots. Its input was busy + queued. It had no idea the slots fed a backend with a concurrency of one. Rejections were real demand, and it answered them with capacity that could not be used.

From the same notes/autoscaling.md policy I still stand behind for slot demand:

target      = busy + queued, clamped to [2, 8]
scale UP    straight to target when queued > 0 for 2 samples (6s), cooldown 8s
scale DOWN  straight to max(demand over last 30s window) when that peak < slots
            for 6 samples (~18s), cooldown 20s

Up-fast is correct when the thing you are adding can do work. Here, adding a worker added a restore, a held slot, and another waiter on Ollama. The cooldown and the window peak did not save me, because the scaler was not flapping. It was converging on a larger waiting room.

It’s the eight checkout lanes and one cashier problem. Opening lanes feels like progress. The line just moved.

Substrate Scope made that easy to miss. Worker bays light up. The restore queue on the board drains because Substrate rejected less often: callers got slots. The wait moved into the turn itself, inside the sandbox, while the actor sat on a worker and the model served one generation at a time. Occupancy looked healthy. Users waited longer.

This is also why agent runtimes have an autoscaler, not a scheduler. Scaling only helps while capacity is elastic all the way down. A replica ceiling, a GPU limit, or a model provider rate limit is the same shape as a local runtime with concurrency of one. Past that line, adding workers has nothing left to give. Something has to lose. The runtime still has no opinion about who.

A CPU HPA would have slept through the original saturation. My scaler did not sleep. It made the second bottleneck worse by feeding it. Wrong signal and right signal with a missing cap are both ways to fail. They fail at different times.

How do you know the model backend is the bottleneck?

You cannot see it on kubectl get pods. You cannot see it on worker CPU. Those workers stay at single-digit mCPU while they wait on the provider, which is why CPU is the wrong up-signal in the first place. You have to look past the slot.

Checks that stay inside what this lab already showed:

  • Scale workers, latency climbs, rejections fall. That is the signature. Callers get in. Turns take longer. The queue moved downstream.
  • One generation at a time. If the backend is a local Ollama (or anything else you have configured for serial generation), worker count above that concurrency is not throughput. It is occupancy cosmetics.
  • The board cannot see the model line. Scope shows worker bays, a client-side restore queue, and a snapshot shelf. It does not show how many generations the model is running. If your only queue chart is restore retries, a serial model queue is invisible by construction.
  • Always-on reservation is the wrong comfort metric here. About 204 MiB and 50m CPU idle per default kagent agent is why Substrate wins on reservation. It does not mean eight workers will get eight answers at once from one serial backend.

If you are on a hosted model where generation concurrency is not the bottleneck, this lesson is a gate you still run, not a story you skip. Provider rate limits are the same cashier with a nicer logo.

What did you change after the serial Ollama queue?

Three changes, all in the lab runbook now:

  • Capped load generator concurrency to 2 against Ollama, matching what the backend could actually serve.
  • Moved demos to a hosted model, where generation concurrency is not the bottleneck.
  • Started treating model backend concurrency as an upper bound on useful worker count, not a detail.

The clamp in the scaler was already [2, 8]. The 8 was a laptop ceiling so the pool could not walk off the machine. It was not “the model can do 8.” After this night, the useful ceiling is the concurrency of whatever serves the tokens, not the clamp. I capped the load generator to 2 against Ollama, matching what the backend could actually serve, instead of letting slot demand walk the pool toward 8.

The floor of two still stands, for a different reason. One worker means any long session blocks every other agent. Know the model concurrency before you copy the policy.

I did not throw away rejection-based scaling. I stopped treating it as sufficient. Slot demand is still the up-signal. Model concurrency is a cap on how far that signal is allowed to push the pool. Ghost actors are a third way occupancy lies: a slot can be busy with no live turn. Serial models are the way occupancy tells the truth about the wrong resource.

How do you test worker scale against a serial model backend?

A checklist I would run before I turn AUTOSCALE on in front of any model I do not already know.

  1. Write down backend concurrency. Local Ollama in this lab: one generation at a time. Hosted model: whatever the provider will actually run. If you cannot state the number, you do not have a cap.
  2. Baseline with workers and generator matched to the backend. I capped the load generator concurrency to 2 against Ollama, matching what it could actually serve. Match the generator to the backend first, then talk about the pool.
  3. Hold the generator there and add a worker by hand. kubectl scale workerpools.ate.dev kagent-default -n kagent --replicas=N with N above concurrency. Watch turn time, not CPU. If turns get slower and rejections drop, you have reproduced the waiting room.
  4. Repeat with AUTOSCALE on. Fill the pool, let rejections appear, let busy + queued add workers. Same signature as step 3 means the scaler is doing its job and you still lost. That is this lesson. Do not “tune the cooldown” to hide it. Put a cap on useful replicas.
  5. Confirm the board’s blind spot. Restore queue drains, bays light up, model wait is not on the board. If you only watch Scope, you will call this a success.
  6. Cap the generator. Against Ollama I capped concurrency to 2. Against a hosted model I stopped using the local serial path for demos. The test is whether the waiting-room signature disappears when generator, pool, and backend agree.
  7. Record the cap next to the clamp. Floor of two, ceiling of whatever the machine and the model allow. Helm --force-conflicts still applies if you scaled through kubectl scale. That trap did not cause this failure. It will cause the next one if you only fix latency.

Pass condition: you can name the serial step, and the WorkerPool cannot grow past it without a human changing that cap. Fail condition: occupancy is high, users are slower, and you add another worker because rejections went to zero.

Scale the bottleneck, not the thing in front of it. Before you scale agent workers, know the concurrency of whatever serves the tokens: a local runtime, a GPU, or a provider rate limit. If the model is the constraint, more workers is just a more expensive waiting room.

The talk recap is the hub. The field guide index is Agent Substrate. The scaler notes and the stimulator live in themsquared/kagent-substrate-demo.

Frequently asked questions

Why would autoscaling agent workers make latency worse?

If the model backend serves one generation at a time, more workers just means more agents waiting on the same generation queue. The bottleneck moves from the worker pool to the model, and per-turn latency climbs.

Was the Agent Substrate autoscaler wrong in that lab?

No. It did what I told it to. Its input was busy plus queued. Rejections were real demand. It answered them with slots that all fed a backend with concurrency of one, so the extra workers were a more expensive waiting room.

What should cap useful WorkerPool size?

The concurrency of whatever serves the tokens: a local runtime, a GPU, or a provider rate limit. Treat that as an upper bound on useful worker count. If the model is the constraint, adding workers does not add throughput.

What did you change after the serial Ollama queue?

I capped the load generator concurrency to 2 against Ollama, matching what the backend could actually serve, and moved demos to a hosted model where generation concurrency was not the bottleneck. Model concurrency is now an input to pool size, not a detail.

Disagree or have a war story? Reply on X