The Workers Service provides access to Temporal worker management, allowing you to monitor worker health, manage registrations, and control worker lifecycle operations.
Overview
Workers in Kubiya are Temporal workers that execute agent tasks and workflows. The Workers Service enables you to:- Monitor Workers: List and inspect all registered workers in your organization
- Worker Registration: Register new workers with the Control Plane
- Health Management: Send heartbeats and monitor worker health
- Lifecycle Control: Start and disconnect workers programmatically
Workers are typically managed automatically by the Kubiya platform, but the Workers Service provides programmatic access for advanced monitoring and management scenarios.
Quick Start
Core Concepts
Workers vs Task Queues
In Temporal terminology, workers poll task queues for work. In Kubiya:- Worker: A physical process that executes agent tasks
- Task Queue: A logical queue that workers poll for tasks
- Runner: The deployment unit that hosts workers
Worker Lifecycle
- Registration: Worker registers with Control Plane on startup
- Heartbeats: Worker sends periodic heartbeats to indicate health
- Active: Worker is polling for and executing tasks
- Disconnected: Worker gracefully shuts down or loses connection
Basic Usage
List All Workers
Example Response
Example Response
Get Worker Details
Worker Management
Register a Worker
Send Worker Heartbeat
Send Simple Heartbeat
Start a Worker
Disconnect a Worker
Practical Examples
The following examples show how to use the Workers Service for real-world scenarios, such as monitoring worker health, managing registrations, and handling worker lifecycle operations. Each example includes a short explanation of when and why you might use it.1. Worker Health Monitor
Use this pattern to build periodic health checks or dashboards that surface unhealthy or stale workers before they impact SLAs or user-facing workflows. Monitor all workers and alert on unhealthy workers:2. Worker Capacity Planner
Use this analysis when you need to understand how workers are distributed across task queues and capabilities so you can plan capacity, rebalance load, or justify scaling decisions. Analyze worker capacity and utilization:3. Worker Registration with Retry
Use this approach when you own the worker deployment pipeline and want resilient registration logic that automatically retries transient failures instead of failing a rollout. Register a worker with automatic retry on failure:4. Graceful Worker Shutdown
Use this strategy when you need to drain workers for maintenance or deployments without dropping tasks or interrupting long-running jobs. Implement graceful worker shutdown:Error Handling
Worker operations can fail for several reasons: a worker might not exist anymore, registration data can be invalid, or network and authentication issues can prevent the Control Plane from responding. The following patterns show how to handle worker-specificWorkerError exceptions alongside common SDK errors, so your monitoring and management scripts fail gracefully.
Best Practices
Follow these practices to keep your worker fleet observable, reliable, and easy to operate as it grows across environments and regions.1. Monitor Worker Health Regularly
Run lightweight periodic health checks so you can catch unhealthy or stale workers early and react before they cause incidents.2. Implement Heartbeat Loops
Implement dedicated heartbeat loops in your worker processes so the Control Plane always has an up-to-date view of their status, even when they are idle.3. Handle Worker Disconnections Gracefully
Always disconnect workers through the API and check for pending tasks so you can avoid leaving workflows half-finished or stuck.4. Use Metadata for Worker Tracking
Include rich metadata when registering workers so you can slice and filter your fleet by environment, region, version, or team when debugging or planning capacity.API Reference
Methods
Worker Object Structure
Registration Data Structure
Heartbeat Data Structure
Next Steps
Agents Service
Manage Control Plane agents
Secrets Service
Manage secrets and credentials
Error Handling
Handle SDK exceptions
Best Practices
SDK best practices guide