Skip to main content
The gateway now ships in the praisonai-bot package. praisonai serve gateway still works exactly as documented here; for a standalone install see praisonai-bot Migration.
This page covers the gateway reliability preset (drain + admission). For task/workflow retry (retry jitter, workflow_timeout, fail_on_callback_error), see Reliability.
One parameter composing graceful drain and inbound admission control into a production-ready configuration — without touching individual knobs.

Quick Start

1

Python (BotOS)

2

Override specific knobs

Explicit args always beat the preset — useful for canary deployments:
3

YAML (gateway.yaml)

4

CLI


Profiles

max_concurrent_runs is calculated as os.cpu_count() * 4, clamped to the range [4, 32]. On a 4-core machine that’s 16 concurrent turns; on an 8-core machine, 32. Unknown profile names fail fast with ValueError.

What Each Knob Does

Graceful drain — on BotOS.stop(), the gateway quiesces ingress and waits for in-flight agent turns to finish before cancelling tasks. The drain window is the maximum time to wait. Inbound admission control — caps the number of concurrent agent runs across all channels. Excess turns either queue (bounded fair wait) or are rejected immediately, depending on the overflow_policy.

Precedence Ladder

Explicit constructor fields always win over the preset. Only fields left unset are filled by the preset.
Example — preset sets drain to 15s, but explicit override wins:

Which Profile Should I Pick?


What It Does NOT Change

These are already default-on regardless of the reliability preset:
  • Durable inbound journal (session level)
  • Durable outbound outbox

Best Practices

The preset values (15 s drain, CPU × 4 ceiling, 32-deep queue) are conservative defaults tuned for latency-bound LLM workloads. Only override a value after measuring that the default doesn’t fit — e.g. a 99th-percentile turn time of 25 s warrants drain_timeout=30.
reliability="production" ensures in-flight conversations finish before a new version takes over. Pair with a process manager that sends SIGTERM on deploy.
reliability="default" (or None) gives you a 5-second drain so you don’t cut conversations mid-turn during Ctrl+C, without the admission overhead of production mode.
reliability="off" restores the pre-reliability behaviour (immediate cancel on SIGTERM, unbounded concurrency). Use it only in tests — never deploy off to production.
If the preset drain window or admission ceiling doesn’t fit your load, pass drain_timeout= or max_concurrent_runs= directly — they always take precedence over the preset. See the Graceful Drain and Admission Control pages for the full knob reference.

Gateway Graceful Drain

Drain-only knob — fine-grained drain control without the full preset

Gateway Admission Control

Concurrency ceiling and fair queue — the other half of the production preset

Config Reload

Hot-reload gateway.yaml without dropping in-flight turns

Reliability

Task/workflow retry jitter and failure policies