Documentation
¶
Overview ¶
Package worker is the headless host that executes agent runs queued by other processes (a web server, an API, a scheduler): it connects to the shared Redis queue and Postgres store, consumes runs, and exposes an admin HTTP server (/healthz, /readyz, /metrics). Several workers can run in parallel, each with its own sandboxes.
Index ¶
Constants ¶
const DefaultAddr = "127.0.0.1:9090"
DefaultAddr is the admin address when neither Options.Addr nor HARNESS_WORKER_ADDR is set.
Variables ¶
var ErrPrivateQueue = errors.New("worker: the run queue is in memory, private to this process, so no other process can queue work for it (connect Redis, or pass Standalone)")
ErrPrivateQueue: the worker's run queue lives in its own memory, so it could never receive work.
Functions ¶
func Run ¶
Run builds the harness, serves the admin endpoints and consumes runs until ctx is done (or, with Once, until the queue is drained). On ctx done it stops claiming, lets in-flight runs finish for RUNTIME_SHUTDOWN_GRACE_SECONDS (then the runtime interrupts them and records why) and returns nil.
Types ¶
type Options ¶
type Options struct {
// Config is the environment configuration (default: config.Load()).
Config *config.Config
// Addr is the admin listen address (default: HARNESS_WORKER_ADDR, else 127.0.0.1:9090).
Addr string
// Standalone allows a private in-memory queue and store (a single process; mostly for tests and demos).
Standalone bool
// Once processes the queued runs until none is queued or running, then returns.
Once bool
// IdleFor is how long the queue must stay empty in Once mode (default 1 s).
IdleFor time.Duration
// RuntimeID names this worker in run ownership (default: hostname-random).
RuntimeID string
// Overrides, mostly for tests; nil builds them from Config.
Store harness.Store
Redis redis.UniversalClient
Models llm.Factory
Backend sandbox.Backend
// OnListening is called with the admin address once the server accepts connections.
OnListening func(addr string)
}
Options configures Run. The zero value reads everything from the environment.