Quick Start
In-Process (Default — No Change Needed)
Without a relay transport, the bot adapter runs in the same process as the gateway. This is the default and requires no extra config:
Out-of-Process via Relay Transport
Pass a
transport= to the Bot constructor to use a remote connector. The transport= parameter is optional and backward-compatible:How It Works
At handshake time the connector attests aCapabilityDescriptor — the gateway uses this to adapt streaming, markdown, and message-length behaviour to the actual platform being fronted, even though it never touches the platform socket directly.
CapabilityDescriptor Fields
The connector attests these capabilities at handshake time:
| Field | Type | Default | Description |
|---|---|---|---|
max_message_length | int | required | Maximum outbound message length the platform accepts |
length_unit | str | "chars" | How length is measured: "chars" (Unicode code points) or "utf16" (UTF-16 code units) |
supports_edit | bool | False | Platform supports editing a sent message (enables draft-streaming) |
supports_draft_streaming | bool | False | Connector can stream partial drafts incrementally |
markdown_dialect | str | "none" | Markdown flavour: "none", "markdown", "markdownv2", "html" |
RelayTransport Protocol
Implement these methods to create a custom transport:
| Method | Description |
|---|---|
connect() -> CapabilityDescriptor | Establish relay and complete handshake; returns connector capabilities |
set_inbound_handler(handler) | Register coroutine called for each inbound event |
send_outbound(target, message) -> DeliveryResult | Relay an outbound message to a target via the connector |
go_dormant() | Pause inbound dispatch without dropping the connection (scale-to-zero) |
disconnect() | Tear down the relay connection |
When to Use a Relay
Scale-to-Zero with go_dormant()
When the gateway scales to zero, call go_dormant() to pause inbound dispatch:
Best Practices
Use go_dormant() during scale-to-zero, not disconnect()
Use go_dormant() during scale-to-zero, not disconnect()
disconnect() tears down the connection and the connector stops buffering. go_dormant() keeps the connector alive and buffering, so events that arrive while the gateway is sleeping are drained on wake.Capability negotiation at handshake
Capability negotiation at handshake
Always use the
CapabilityDescriptor returned by connect() to configure your delivery layer. Never hard-code platform limits — the connector is the authority on what the actual platform supports.The transport= parameter is optional
The transport= parameter is optional
Omit
transport= entirely to keep the existing in-process behaviour. No existing code needs to change; just add the parameter when you need an out-of-process connector.Related
Gateway Overview
How the gateway connects agents to channels
Gateway Scale-to-Zero
Idle dormancy and wake-up behaviour
Durable Outbound Delivery
Retry and DLQ for all channels
Multi-Channel Bots
One gateway, many platforms

