This release is a pre-release and may not be stable for production use.
Avtomatika Worker SDK
Official SDK for building workers compatible with the Avtomatika orchestrator. It automates low-level tasks: polling, heartbeats, S3 payload management, and graceful shutdown.
🚀 Key Features
- Language: Python 3.11+
- Protocol: Based on RXON (Reverse Axon Protocol) for Hierarchical Logic Networks (Holarchy).
- Communication Model:
- PULL: Workers poll tasks from orchestrators (works behind NAT/Firewall).
- WebSocket: Real-time command channel (cancellation, custom commands).
- Zero Trust Security & Policy Enforcement:
- Mandatory HMAC SHA256 signing for all messages using
WORKER_TOKEN. - Verification of
orchestrator_signatureon incoming tasks before execution. - Strict enforcement of
allowed_skillstask execution policies. - Automatic collection and reporting of task execution cost metrics (
costs). - Identity Chain and Origin Worker ID support for provenance tracking.
- Replay protection with timestamp validation.
- Mandatory HMAC SHA256 signing for all messages using
- Traffic & Performance Optimization:
- Telemetry Throttling (Heartbeat Deadband): Telemetry (CPU/RAM/GPU) is only sent when value changes by $>5%$ or after 60s force interval, drastically saving bandwidth.
- ETag-Based Blob Caching: Heavy assets (e.g. AI model weights) are downloaded only once, cached locally, and symlinked to tasks' workspace.
- Async Results Uploader: Task results are sent using a non-blocking
asyncio.Queuewith retry policy, rate limiting wait times, and backoff, instantly freeing the worker for the next task. - 3-Tier Skills: Supported (catalog), Available (dynamic limits), and Hot (cached).
- Stable Hashing: Sends full skill catalog only when changed, using
skills_hashfor light heartbeats.
- S3 Streaming: High-performance data transfer using
obstore. No OOM on large files. - AI-Agent Support: Supports Chain of Thought and Tool Use via
OrchestratorClientdependency injection for subtask delegation. - Hardware Awareness: Built-in monitoring for CPU, RAM, and NVIDIA GPUs (via
psutilandGPUtil). - Observability:
- Built-in support for OpenTelemetry (traces and metrics).
- Automatic Trace Context Propagation: Workers extract
trace_idfrom tasks and inject it into events (including progress), ensuring end-to-end visibility in Jaeger/Honeycomb. - Automatic metrics export via OTLP (Push model) when
OTEL_EXPORTER_OTLP_ENDPOINTis configured.
🛡 Resilience & Connectivity
- Independent Managers: Connection to each orchestrator is managed by a separate background task. One server failure or rate limit doesn't affect others.
- Smart Backoff: Unified exponential backoff for registration, polling, and heartbeats.
- Rate Limit Protection: Full support for
Retry-After(seconds or HTTP-date). Implements a mandatory 30s safety floor for 429 errors withoutRetry-Afterto prevent Retry Storms. - Heartbeat Debouncing: Throttles heartbeats to once every 2 seconds. Events are not lost but consolidated and sent after the cooldown period.
- Infinite Retries: Workers never stop trying to register with an exponential delay.
- Graceful Shutdown: Handles
SIGTERMandSIGINTproperly, waiting for active tasks to finish.
🛠 Installation
pip install avtomatika-worker[s3,pydantic]
For development:
pip install -e .[test,dev]
💻 Quick Start
from avtomatika_worker import Worker, TaskFiles, OrchestratorClient
worker = Worker()
@worker.skill("hello_world")
async def my_skill(params: dict, files: TaskFiles):
"""Simple skill that says hello."""
return {"message": f"Hello, {params.get('name', 'World')}!"}
@worker.skill("ai_agent_reasoning")
async def agent_skill(params: dict, orchestrator_client: OrchestratorClient):
"""AI agent skill delegating a subtask (tool use) via OrchestratorClient."""
search_result = await orchestrator_client.call_skill("web_search", {"query": params["search_query"]})
return {"result": f"Based on web search: {search_result['data']}"}
@worker.on_command("reboot")
async def handle_reboot(command):
print("Rebooting worker...")
if __name__ == "__main__":
worker.run()
⚙️ Configuration
Controlled via environment variables:
ORCHESTRATORS_CONFIG: JSON list of orchestrator configs (URLs, priorities, weights).ORCHESTRATOR_URL: Simple fallback if only one orchestrator is used (default:http://localhost:8080).WORKER_TOKEN: Secret for HMAC signing (Zero Trust).S3_ENDPOINT_URL,S3_ACCESS_KEY,S3_SECRET_KEY,S3_DEFAULT_BUCKET: Storage settings for large payloads.WORKER_BLOB_CACHE_DIR: Directory for caching S3 blobs (default:/tmp/avtomatika_cache).WORKER_TELEMETRY_DEADBAND: Threshold (percent) for throttling telemetry updates (default:5.0).WORKER_TELEMETRY_FORCE_INTERVAL: Maximum time (seconds) to wait before sending telemetry even if unchanged (default:60.0).STRICT_EVENT_VALIDATION: (Default:True) Validates events against schemas before emitting.LOG_LEVEL: Logging verbosity (DEBUG, INFO, WARNING, ERROR).POLL_BACKOFF_INITIAL: Initial delay (seconds) after a 429 error or network failure (default:1.0). HonorsRetry-Afterheader.POLL_BACKOFF_MAX: Maximum backoff delay (seconds) (default:60.0).POLL_BACKOFF_FACTOR: Multiplier for exponential backoff (default:2.0).MAX_CONCURRENT_TASKS: Global limit for concurrent task execution.
📜 License
Mozilla Public License v. 2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file avtomatika_worker-1.0b19.tar.gz.
File metadata
- Download URL: avtomatika_worker-1.0b19.tar.gz
- Upload date:
- Size: 76.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Gentoo","version":"2.18","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16481b95eee0b41c12fa7bcc3ee039085effe4faa128616186e9bebf4c9564cc
|
|
| MD5 |
871a470ea56e4a9befaf903e91526f49
|
|
| BLAKE2b-256 |
296b8f71310f2a2d861dd9ede18aa1a3c4ba8c8ee0c3d8180e06fffb67a4903a
|
File details
Details for the file avtomatika_worker-1.0b19-py3-none-any.whl.
File metadata
- Download URL: avtomatika_worker-1.0b19-py3-none-any.whl
- Upload date:
- Size: 42.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Gentoo","version":"2.18","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03953886ee516f57751a31a2483606b70a615f6493a49a9a524134695cba9deb
|
|
| MD5 |
8a64191c30d3d51183e68079f939ebf3
|
|
| BLAKE2b-256 |
f119ba36389d69cbc9a5d520ade4a70b1c44ad32feb315d78d08d334e1b1051d
|