Get Started
Dispatcher-free Mode
Lightchain AI assigns jobs on the chain itself. A central dispatcher service used to pick the worker for each session; it no longer runs on testnet or mainnet. In dispatcher-free mode a worker watchesSessionManager for session requests it is eligible for, claims one with a single transaction (sortition — a weighted random draw among eligible workers), and then serves that session's jobs from JobRegistry exactly as before. No service picks the worker; the contract does.
CodeTEXT
Where it is live
Check either network yourself:CodeBASH
Run profiles
One image, three profiles, selected by two environment variables:SORTITION_ENABLED=true also requires SESSION_MANAGER_ADDRESS; the worker refuses to start without it. When both SORTITION_ENABLED and WORKER_GATEWAY_URL are set, the startup log carries the line external worker profile: sortition assignment with gateway egress (responses, heartbeat, drain via worker-gateway).
The gateway for the external profile is https://worker-gateway.testnet.lightchain.ai on testnet and https://worker-gateway.mainnet.lightchain.ai on mainnet.
Environment reference
Everything below is read by the sidecar; the CLI reads the chain and identity variables too. Chain, identity, model and inference variables (CHAIN_ID, RPC_URL, the *_ADDRESS set, WORKER_KEYSTORE_*, ENCRYPTION_KEYSTORE_PATH, SUPPORTED_MODELS, OLLAMA_URL, BEACON_API_URL, BLOB_MODE) are unchanged from the install guides.
Verify it is claiming
A healthy external-profile start:CodeTEXT
claimed session request, then the usual stage 1: broadcasting ack tx … job completed sequence for each job in that session:
CodeBASH
lightchain-worker preflight (shown in the install guides) checks everything a claim depends on — registration, stake against the live minimum, each model's whitelist / enabled / added state, gateway login, Ollama tags — and exits 1 on any failure. Run it first whenever a registered worker never claims.
Web search
Workers can augment a prompt with a live web search when the user turns on Web search in the chat. The worker runs one Tavily query with the prompt, folds the top results into the prompt it sends to the model, and publishes the sources after the answer so the chat renders them beneath it. Search is fail-open: on any error or timeout the job proceeds with the original prompt and no sources. Enable it with your own Tavily API key:CodeBASH
TAVILY_API_KEY is required when SEARCH_ENABLED=true; the worker refuses to start without it.
What the flag changes on the network side:
- The worker advertises the
searchcapability in its heartbeat, and in dispatcher-free mode declares it on-chain at startup (WorkerRegistry.setCapabilities, one transaction from the worker key, sent only when the mask changes). Sessions that require search are claimable only by workers whose mask includes it; the worker skips requests it cannot satisfy. - Capabilities are an owner-managed namespace: a worker can only declare names the network has registered (
WorkerRegistry.getCapabilityCount()). Both testnet and mainnet havesearchregistered (mainnet since 2026-09-13). A worker started before its network registered a capability logscapability not registered on-chain; skipping declarationand declares it on its next start. - Both published images (
registry.lightchain.ai/testnet/worker:latestandmainnet/worker:latest, worker releasev0.0.5since 2026-10-16) support web search; a mainnet image pulled before 2026-09-13 does not.
Stopping a dispatcher-free worker
lightchain-worker drain sets a marker that the dispatcher used to honour. Nothing consults it before a claim, so a running worker keeps claiming sessions until the process stops. To take a worker out of rotation:
-
Stop it:
On SIGTERM the worker stops both watchers at once, so it claims no new session and starts no new job, and sets the drain marker through the gateway. Jobs it is already running keep going until they finish orCodeBASH
SHUTDOWN_TIMEOUTruns out (the install guides set 240 s; unset, it is 30 s). A job still running then is cancelled, times out on-chain, and counts as an offence. Keepdocker stop -taboveSHUTDOWN_TIMEOUT, or Docker kills the worker first. This is worker release v0.0.5 and later: an older image ends a running job at SIGTERM, so pulllatestbefore you rely on it. - Jobs submitted later in sessions you already claimed still target your worker. While it is offline they time out, and every timeout is recorded as an offence even while slash rates are 0 — see Slashing & Rehabilitation.
- To leave for good, continue with the release and deregister steps in Drain & Graceful Exit.
Related pages
- Run a Worker — Testnet — the full external-profile install.
- Run a Worker — Mainnet — the full external-profile install on mainnet, plus how to move a worker set up with the older commands.
- Drain & Graceful Exit · Slashing & Rehabilitation
- AIVM EL Architecture — sortition, verification and slashing in the protocol design.