Skip to content

ContextWorker

ContextWorker is the “Hands” of the ContextUnity ecosystem. It provides durable workflow infrastructure, scheduled jobs, and sub-agent execution — all built on Temporal.io.

Durable Workflows

Temporal.io workflows that survive restarts and failures, with automatic retries and state persistence.

Scheduled Jobs

Cron-based recurring tasks — harvesting, enrichment, catalog sync, data retention.

gRPC Service

Trigger and monitor workflows from other services via ContextUnit protocol.

Sub-Agent System

Isolated execution environments for agent-generated code with Brain recording.

Architecture

src/contextworker/
├── __main__.py # CLI: gRPC service (default) or --temporal
├── config.py # WorkerConfig (Pydantic settings)
├── service.py # gRPC WorkerService
├── server.py # gRPC server setup
├── schedules.py # Temporal schedule management
├── interceptors.py # gRPC interceptors
├── core/
│ ├── registry.py # WorkerRegistry, ModuleConfig, plugin discovery
│ └── worker.py # Temporal client setup and worker creation
├── subagents/ # Sub-agent execution framework
│ ├── executor.py # SubAgentExecutor (orchestrator)
│ ├── isolation.py # IsolationManager, IsolationContext
│ ├── brain_integration.py # Step recording to Brain
│ ├── local_compute.py # Sandboxed Python execution
│ ├── rlm_tool.py # RLM tool integration
│ └── monitor.py # Execution monitoring
└── jobs/
└── retention.py # Data retention policies

Key Design Principle

Worker contains NO business logic. It provides infrastructure only.

Business logic lives in domain packages:

  • Commerce harvesting → ContextCommerce (registers workflows)
  • AI enrichment → ContextRouter (runs agents)

Modules register themselves via the WorkerRegistry and are discovered at startup.