Skip to main content
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.
Gateway Attachments is a typed, additive, size-bounded contract so any /ws client can send a file to an agent and receive agent-generated artefacts back over the same connection.
An attachment travels one of two ways: inline base64 for small files, or by reference to a chunked entry in the gateway attachment store for large files. The gateway advertises its size and type ceilings in 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 a message 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

An AttachmentRef carries the file two mutually exclusive ways. An inline attachment sets data:
A by-reference attachment sets ref_id instead:
The same shape is reused outbound: agent-generated files surface as 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:
When attachments are disabled (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.
The contract lives in the dependency-free core so every client agrees on one shape. The concrete durable store (filesystem / object store) is intentionally a wrapper/bot concern, kept out of the core to preserve its no-heavy-import rule.

Validation Rules & Failure Modes

Each rule below rejects with a FrameDecodeError 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 HelloResult.policymax_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.
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.
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.

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.