Handler Routing
How the worker matches executions to handlers using payload.task.
How routing works
When the worker receives an execution, it looks at payload.task and matches it to a handler in the YAML config:
Execution payload: {"task": "draft-linkedin", ...}
↓
Worker config handler: draft-linkedin:
cmd: "python3 linkedin_agent.py"
Routing rules
payload.taskmust exactly match a handler key in the config- If no handler matches, the execution is skipped (not claimed)
- The worker only claims executions it can handle
- Multiple workers can have different handler sets
Example
Config:
yaml
handlers:
draft-linkedin:
cmd: "python3 linkedin_agent.py"
timeout: 300
sync-data:
cmd: "/scripts/sync.sh"
timeout: 60| Payload task | Matched handler | Result |
|---|---|---|
draft-linkedin | draft-linkedin | Claimed and executed |
sync-data | sync-data | Claimed and executed |
unknown-task | (none) | Skipped |
Filtering at the API level
The worker uses the ?task= query parameter when polling to only fetch relevant executions:
GET /v1/executions/claimable?task=draft-linkedin,sync-data
This reduces unnecessary polling and network traffic.
Multiple workers
You can run multiple workers with different handler sets:
Worker A (content pipeline):
yaml
handlers:
draft-linkedin:
cmd: "python3 linkedin_agent.py"
draft-twitter:
cmd: "python3 twitter_agent.py"Worker B (data tasks):
yaml
handlers:
sync-data:
cmd: "/scripts/sync.sh"
generate-report:
cmd: "python3 report.py"Each worker only claims executions matching its handlers.