Skip to main content
Custom channel adapters implement SupportsGatewayRuntime to receive the gateway’s four reliability seams; miss the contract and the gateway fails loudly instead of silently dropping admission control, delivery routing, and cross-platform turn locking.

Quick Start

Adapters that build a BotSessionManager satisfy the contract for free; others implement one method.
1

You don't have to do anything

Delegate to BotSessionManager — it already implements the contract, so your adapter inherits it through self._session.
2

Implement the contract yourself

Define attach_gateway_runtime and copy each non-None seam exactly as BotSessionManager does — a None seam means “keep what you already have”.

How It Works

The gateway builds each adapter once, then hands it a typed GatewayRuntimeSeams carrier through attach_gateway_runtime. The gateway resolves the target in a fixed order:

The Four Seams

Each seam maps to a gateway reliability guarantee and a feature doc. A seam left None means the gateway has nothing to inject for it; leave whatever value you already hold untouched.

The Contract

Three symbols define the contract, all imported from one place.
GatewayRuntimeSeams is the typed carrier the gateway fills and passes to your adapter.
SupportsGatewayRuntime is the runtime-checkable Protocol your adapter satisfies.
GatewayAdapterContractError is the loud failure raised when seams cannot be delivered.

When GatewayAdapterContractError Fires

The gateway raises this error only when it has seams to inject but your adapter neither implements attach_gateway_runtime nor exposes a _session / _session_mgr that does — the raise is intentional, replacing a silent loss of reliability guarantees. The fix is one of the two Quick Start options: build a BotSessionManager on self._session, or implement attach_gateway_runtime directly.

Compatibility

The wrapper permits praisonaiagents >= 1.6.152; on a core that predates the contract the import in step 2 fails and the gateway transparently falls back to the pre-contract private-attribute splices (_identity_resolver, _delivery_router, _admission_gate, _locks) written onto adapter._session or adapter._session_mgr.
The legacy fallback is a compatibility shim, not a public API. Write to the contract (attach_gateway_runtime) — the fallback exists solely so older-but-supported installs keep wiring the seams.

Best Practices

If your adapter already builds a BotSessionManager, expose it as self._session and do nothing else. The gateway finds attach_gateway_runtime on the session and wires all four seams for free.
Every seam is optional. A None seam means the gateway has nothing for it — leave your existing value in place. Copy each attribute only when it is not None, exactly as the reference implementation does.
GatewayAdapterContractError means the gateway had reliability seams to inject and your adapter could not receive them. Fix the adapter rather than catching the error; suppressing it silently drops admission control, delivery routing, identity resolution, and per-turn locking.
If your adapter previously relied on the gateway splicing _session._identity_resolver and friends, add a single attach_gateway_runtime method that assigns each non-None seam to the same slot. This makes the wiring explicit and passes the SupportsGatewayRuntime isinstance check.

Bot Platform Plugins

Register a custom platform adapter with register_platform(name, cls).

Bot Platform Adapter

Build a channel adapter by subclassing BasePlatformAdapter.

Gateway Admission Control

The admission gate seam — concurrency ceiling and backpressure.

Cross-Platform Mirror

The identity resolver and turn lock map seams across platforms.