praisonai gateway doctor runs every health check registered against praisonai.health_checks, so a tool or channel package can surface its own status — and optional auto-repair — alongside the built-in gateway checks.
An agent can run the same registry to report live health before answering an ops question.
Quick Start
1
Write a diagnostic-only check
A check needs a namespaced
check_id and a detect method that returns findings without changing anything.2
Advertise it via entry point
Third-party packages expose checks through the The entry point may resolve to a class (called with no arguments) or an instance. Discovery is lazy — it runs on the first
praisonai.health_checks group in pyproject.toml.doctor invocation.3
Run the doctor
Install your package, then run the doctor. Your check appears next to the built-ins.
How It Works
gateway doctor asks the registry for every check, runs each in an isolated try/except, then — with --fix — repairs and re-detects.
Choose Your Check Type
Pick the smallest surface that fits — detect only, add a repair, or go async when you touch the network. Add arepair method to auto-fix, and honour dry_run so --dry-run only previews.
adetect / arepair coroutines when a check hits the network, so it never blocks a caller’s event loop.
Reference
The protocol requirescheck_id and detect; the rest are duck-typed and optional.
HealthCheckResult — one check’s detect → repair → re-validate outcome:
HealthRepairResult — a frozen dataclass returned by repair():
Well-known
context keys the gateway passes to every check:
—fix, dry-run, and JSON output
--fix runs each check’s repair(), and --dry-run is threaded through the shared context so checks preview without writing. --json output carries a top-level health block.
1 whenever any residual Finding with severity == "error" remains — across built-in or plugin checks.
Best Practices
Namespace check_id under your package
Namespace check_id under your package
Use a slash-separated identifier such as
channel/slack/webhook or tool/postgres/connectivity. The registry enforces the / and raises ValueError on an unnamespaced ID.Keep detect() fast and side-effect-free
Keep detect() fast and side-effect-free
detect() runs on every doctor invocation. Probe cheaply, avoid writes, and never mutate external state — repairs belong in repair().Make repair() idempotent
Make repair() idempotent
Repairs may re-run, so a second call should be safe. Return
HealthRepairResult(changed=False, message="…") when there is nothing to do.Honour the dry_run flag
Honour the dry_run flag
Under
--dry-run, context["dry_run"] is True. Return HealthRepairResult(changed=False, message="would …") and write nothing so operators can preview safely.Related
Doctor CLI
Built-in gateway and environment checks.
Gateway CLI
Run, inspect, and validate the gateway.
Gateway Config Migration
How the config-version check migrates
gateway.yaml.
