Skip to content

Seat dispatch

An Assignment queues a turn for a Session bound to an AgentClaim. Create it in the same namespace as the claim. The controller admits one assignment at a time per seat and pins admitted work to the Session it starts on. It queues assignments by creation time and uses the resource name to break ties. Queued assignments can wait for a replacement claim with the same name.

Change and WorkflowRun select idle seats for new work from the requested AgentSet group. Both dispatch through claim-targeted Assignments. Seat discovery uses an indexed view of nonterminal Assignments and confirms queue state against the API server. If the index shows no available seat, a live queue check can find a seat the index still shows as busy. When another caller queues work for the same seat, the Assignment controller handles admission in queue order.

Use the sample Assignment to run the checkout tests.

Terminal window
kubectl --namespace team-a apply -f config/samples/assignment.yaml
kubectl --namespace team-a get assignment checkout-tests --watch
kubectl --namespace team-a get assignment checkout-tests -o yaml

The status reports the phase, observedGeneration, a Ready condition (True once Succeeded and False otherwise), the kagent Session and task IDs, and the text or structured result when available. The controller also publishes Kubernetes Events on terminal and waiting phase transitions. Failed and rejected kagent tasks report a bounded diagnostic in status.message. A waiting task reports its explicit diagnostic there when kagent supplies one. A JSON answer that exceeds the text preview can appear in the structured result. A missed kagent notification is recovered by reading task state on a timer. Enable callbacks for faster task updates.

When the phase is InputRequired or AuthRequired, set spec.reply to an object with a fresh id and the answer in text. The controller sends the answer to the same task in the same Session.

The assignment deadline includes time queued, running, and waiting for a reply. Set spec.deadlineSeconds to change the default of 1,800 seconds. Set spec.inputTimeoutSeconds to limit each wait for input or authorization. Zero uses the overall deadline. Set spec.cancel to true to cancel work and keep its outcome on the resource. The controller stops admitted work before allowing the seat to take more. While kagent cannot confirm a stop, the assignment stays in Stopping and holds the seat. If the opening send’s response is lost, cancellation looks up the original message in the selected Session. When the task already finished, the Assignment records its outcome. Set spec.cancelOnWait when the caller cannot answer a task that needs input or authorization. The assignment preserves the task’s waiting diagnostic when it stops.

The controller expires finished assignments after 24 hours. A Change or WorkflowRun can hold its assignment results past that period while it is still running.

kslip_assignment_dispatch_latency_seconds measures the time from Assignment creation to recording its first kagent task ID. It includes queueing and recovery. kslip_workflow_step_dispatch_latency_seconds starts when the WorkflowRun controller first sees the step’s dependencies satisfied and ends at the same recorded task ID. It includes time spent waiting for an idle seat. kslip_assignment_send_duration_seconds measures each gateway send, with separate series for opening messages and replies and for success and error.

The receiver keeps one pending notification per seat. It counts valid notices in kslip_seat_notifications_total as enqueued, coalesced with a pending notice, or dropped when the bounded queue has no room. Polling still reads task state when a notification is missed.

kslip_seat_notification_reconciles_total counts reconciliations that consume a pending notice, including ones that do not need a task read. kslip_seat_task_reads_total counts whether a task read changed Assignment status, found unchanged status, confirmed the task was missing, or failed. Its source label is notification when a pending notice was present at the start of the reconcile and watch_or_poll otherwise. Watch events, poll timers, and notices share a work queue, so the label records the presence of a hint.