Skip to content

Execution Engines & Jobs

ContextWorker uses pluggable execution engines and a job orchestration layer to run durable workflows, registered tools, and Router graph calls.

Execution Engines

Worker supports multiple execution backends via the engines/ package:

TemporalEngine

Production-grade durable workflows using Temporal.io:

from contextunity.worker.engines.temporal_engine import TemporalEngine
engine = TemporalEngine("localhost:7233")

TemporalEngine implements the BaseEngine methods used by WorkerService: start_workflow(), get_task_status(), and register_schedules().

Temporal workflows survive process restarts, network failures, and server crashes with automatic state persistence and retry.

HueyEngine

Lightweight task queue using Huey for simpler deployments:

from contextunity.worker.engines.huey_engine import HueyEngine
engine = HueyEngine()

Both engines implement the BaseEngine protocol from engines/base.py. The active engine is selected via WORKER_ENGINE.

Built-in Jobs

Worker includes several built-in job types in jobs/:

ModulePurpose
orchestrator.pyDurable execution of registered tools and Router graphs
retention.pyData retention policies and cleanup

Module Registry

Domain-specific plugins register their workflows and activities via the WorkerRegistry:

from contextunity.worker.core.registry import WorkerRegistry
registry = WorkerRegistry()
registry.register(
name="sync",
queue="tenant-a-tasks",
workflows=[SyncWorkflow],
activities=[sync_records, persist_results],
)

Modules are discovered at startup and can be filtered via --modules flag.