The gateway ships in the
praisonai-bot package. praisonai serve gateway works exactly as documented here; for a standalone install see praisonai-bot Migration.Looking for
agent.start(attachments=[…])? That is a different feature — attaching local files to a single agent call so the model sees them as content parts. See Attachments. This page is the gateway wire protocol: how any custom /ws client hands the gateway a file over the connection and gets agent-generated files back./ws client can send a file to an agent and receive agent-generated artefacts back over the same connection.
hello_ok, so a client self-limits and chunks before sending.
Quick Start
1
Send a small inline file
Small files ride inline as base64 in an
AttachmentRef, bounded by the advertised max_attachment_bytes policy.2
Send a large file by reference
Large files stream into the gateway attachment store, then travel by
ref_id.3
Configure ceilings
Set the size and type ceilings in Python or YAML. The gateway folds them into
hello_ok.How It Works
The client reads the advertised policy, self-limits, then sends amessage frame with attachments; the gateway validates each against the policy before dispatching to the agent.
The advertised policy is part of the wider hello_ok contract — see Gateway Handshake Protocol.
Wire Format
AnAttachmentRef carries the file two mutually exclusive ways. An inline attachment sets data:
ref_id instead:
AttachmentRef entries a generic client fetches over the same connection, instead of relying on platform (Telegram/Slack/…) delivery.
A message frame carries them under attachments:
Configuration Options
AttachmentConfig sets the ceilings the gateway advertises and enforces.
AttachmentConfig.enabled is True only when both max_attachment_bytes and max_attachments are positive. Wire it onto GatewayConfig.attachments, or set it in YAML under gateway.attachments.
Advertised Policy
When attachments are enabled,hello_ok gains the attachment keys:
max_attachment_bytes=0 or max_attachments=0), none of these keys are added — the policy is byte-for-byte today’s shape:
allowed_attachment_types appears only when allowed_types is configured. The wider policy story lives in Gateway Handshake Protocol.
AttachmentStoreProtocol
Large files stream into a store that every client and implementation agree on through one core Protocol.Validation Rules & Failure Modes
Each rule below rejects with aFrameDecodeError carrying ConnectErrorCode.CONFIGURATION_ERROR / ConnectRecoveryStep.DO_NOT_RETRY — the same structured envelope the rest of the inbound codec uses (see Frame Codec).
Backward Compatibility
attachments is opt-in per turn: a frame without it decodes exactly as before, since the field defaults to []. When the config is disabled (max_attachment_bytes=0 or max_attachments=0), the advertised policy is byte-for-byte today’s shape — none of the attachment keys are added, so legacy clients see no change.
Best Practices
Read the policy before sending
Read the policy before sending
Read
HelloResult.policy — max_attachment_bytes, max_attachments, chunk_bytes — from hello_ok and self-limit / chunk accordingly. Clients that check first reject early instead of being disconnected mid-turn.Inline small files, store large ones
Inline small files, store large ones
Prefer inline
data for files below chunk_bytes; use reserve → put_chunk → close and send by ref_id for anything larger. Inline avoids a round trip; the store avoids an oversized frame.Advertise your MIME allow-list up front
Advertise your MIME allow-list up front
Set
allowed_types (e.g. ["image/", "application/pdf"]) so the gateway advertises allowed_attachment_types. Clients then reject unsupported files early instead of being disconnected.Disable while keeping the config wired
Disable while keeping the config wired
Set
max_attachment_bytes=0 or max_attachments=0 to advertise a byte-identical legacy policy while keeping gateway.attachments in place — flip the ceilings positive to enable without a config restructure.Related
Gateway Handshake Protocol
Where
HelloResult.policy lives — the advertised attachment ceilings.Frame Codec
Where
MessageParams lives — the message frame that carries attachments.Gateway Client
The client that sends and receives frames over the
/ws connection.Attachments
The different,
agent.start(attachments=[…])-level feature — local files as model-visible content parts.
