Practical technical guides

Pause, Drain and Reconfigure Agent Workers Through a Control Bus

Versioned control state, per-worker acknowledgements and step-boundary rules for pausing intake, draining runs and changing models safely.

By Sandeep Belgavi · Published 2026-12-06

Flow from Versioned control state, to Apply at step boundaries, to Acknowledge per worker.
Original conceptual diagram by Sandeep Belgavi.

Why agent workers need a control channel

An agent platform at Belgavi's Book Store runs a pool of workers. Each worker takes a help-desk case from a queue, runs an agent loop over several steps, calls tools, and writes a result. Operators regularly need to do things to that pool that are not part of any case: stop taking new refund cases while a payment provider is degraded, finish in-flight work before a deploy, switch the model used for drafting replies, or lower the number of parallel tool calls. Teams usually start with a redeploy for each of these. Then they add an environment variable, then a feature flag read at startup, and eventually discover that half the fleet applied the change and half did not.

Enterprise Integration Patterns describes a Control Bus: a separate channel that carries control messages, such as configuration changes, start and stop commands and status requests, to the components of a messaging system, using the same messaging infrastructure as the application data but kept apart from it. The point is not the channel technology. It is that control is expressed as messages with identity, versions and acknowledgements, instead of as side effects of a deploy.

The control state, not the command

The most robust design treats control as desired state with a version, not as a stream of imperative commands. A worker that reconnects after a network blip should not need to replay "pause", "resume", "pause" in order. It should read the latest control state and converge on it.

{
  "version": 42,
  "issued_by": "Geetha",
  "issued_at": "2026-12-06T09:40:00Z",
  "intake": {"refund": "paused", "exchange": "open", "address": "open"},
  "drain": false,
  "model": {"drafting": "drafter-2026-11"},
  "limits": {"parallel_tool_calls": 2},
  "reason": "Payment provider degraded; refunds paused until status is green"
}

Each worker applies a version and reports back what it applied:

{"worker": "w-07", "applied_version": 42, "in_flight": 3, "state": "running", "reported_at": "2026-12-06T09:40:04Z"}

The operator view is the join of the two: the desired version, and for each worker the applied version, its in-flight count and the age of its last report. A change is complete when every live worker reports the desired version. Until then it is in progress, and the operator can see exactly which workers lag.

When a worker may apply a change

The hardest design question is where in an agent run a control change takes effect. An agent run is not a single request; it is a sequence of model calls and tool calls, some of which have side effects. Three rules work well:

  1. Intake changes apply before dequeuing. A paused intake for refunds means the worker does not take new refund cases. In-flight refund cases continue.
  2. Configuration changes apply at step boundaries. A new model for drafting takes effect at the next model call that starts after the worker applied the version. The run records which version each step used, so a reviewer can explain a case that switched models halfway.
  3. Drain means finish, then stop taking work. In-flight runs complete their current step and continue to the end, or to the next durable checkpoint if the run is resumable, and the worker reports drained when its in-flight count reaches zero.

What a control message must never do is interrupt a tool call that has a side effect. A worker that receives "stop" while a refund call is in flight cannot know whether the refund happened. Stopping there converts an operational action into an unknown-outcome problem for the payment reconciliation team.

def apply_at_step_boundary(run, desired, applied):
    """Called by the worker loop before starting each agent step."""
    if desired.version == applied.version:
        return applied
    run.log("control_applied", version=desired.version, previous=applied.version, step=run.next_step)
    return desired

def may_dequeue(case_kind, control):
    if control.drain:
        return False
    return control.intake.get(case_kind, "open") == "open"

What stays deterministic

The control state, its versioning, the rule for when each kind of change applies, and the acknowledgement protocol are all deterministic code. No model reads the control channel. In particular, do not send control instructions into the agent's context ("you are paused, do not issue refunds"). The agent might comply, partially comply, or explain to the customer that it is paused. Pausing is a property of the worker loop and the tool layer, not of the prompt. If a refund tool must be unavailable, the tool layer refuses the call with a clear error, and the agent handles that the same way it handles any refused tool.

A worked example

Suppose eight workers, w-01 to w-08, each with up to four runs in flight. At 09:40 Geetha publishes version 42, pausing refund intake. Within four seconds seven workers report version 42. Worker w-05 reports version 41 because it is in a long tool call and its loop reads control only between steps. The operator view shows 7 of 8 applied, and w-05 with two in-flight runs. Thirty seconds later w-05 finishes its step, applies version 42, and the view shows 8 of 8.

Now consider a drain before a deploy at 10:15. Version 43 sets drain: true. In-flight counts fall from 21 to 6 within two minutes. Three workers reach zero and report drained. One run on w-02 is waiting for a human approval and will not finish for an hour. The protocol has to say what happens to it: either the run is durable and can be resumed on a new worker after the deploy, in which case the worker checkpoints and releases it, or the deploy waits. A drain that ignores long waits either never completes or kills work that was not safe to kill.

Failure modes

  • Silent partial application. Without acknowledgements, a change looks complete because the publish call succeeded. Always show applied versions per worker and the count of workers that have not reported recently.
  • Version regression. A worker restarts with a stale local cache and applies an older version. Workers must refuse versions lower than the highest they have applied and fetch the current state on startup.
  • Control and data share a queue. A backlog of cases delays the pause command behind the very work it is meant to stop. Use a separate channel or a separately read key, and read it on every loop iteration.
  • Missing worker looks applied. A crashed worker does not report and is not in the list. Track workers by heartbeat and show missing ones explicitly.
  • Pause in the prompt. The agent is told it is paused and tells a customer something misleading. Keep control out of model context.

Migration steps

  1. Inventory what operators already change by redeploy, environment variable or flag, and classify each change as intake, configuration, limit or drain.
  2. Introduce the versioned control state with only the current values, and make workers report applied versions. Do not change behaviour yet.
  3. Move one control, usually refund intake, from a deploy-time setting to the control state, with the step-boundary rule written down.
  4. Add drain, and decide how long waits such as human approvals or durable timers are handled before the first deploy that uses it.
  5. Remove the old mechanisms once the operator view shows every change reaching every worker.

When an agent is unnecessary

A control bus is an operations pattern. It pays off for any worker fleet with side effects, with or without an agent. If your agent runs as a single synchronous request inside an existing web service, the service's existing deploy and flag tooling may be enough; the control bus earns its cost when runs span minutes or hours, cross several tool calls, and must be paused or drained without guessing what is in flight.

Verification

Test the worker loop with a fake control store: publish a new version mid-run and assert that the next step uses it and the current tool call is not interrupted. Test version regression by feeding an older version. Test drain with a run that is blocked on an approval. In staging, publish a version and measure the time until every worker acknowledges it; that number is your control latency, and operators should see it before they rely on a pause during an incident.

Primary references and authorship

Sources read December 6, 2026. Original explanations, measurements and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/agent_control_bus. Views are my own and do not represent any employer, past or present.