Going to production
Before you ship AI Transport in production, walk through this checklist. It covers the operational concerns that come up across every feature.
Work through each item before traffic moves to production.
Pricing
AI Transport is priced on the number of unique users that interact with your application each month. Before you go to production, check that all users will be identified correctly:
- Give each user a distinct
clientIdand use it on every device. A user who joins from their phone and laptop with a differentclientIdcounts as two MAUs. - Create your agent's realtime client from the server package. Server clients aren't counted as MAUs. On token authentication, the agent's token must also carry the
x-ably-clientTypeclaim with the valueserver.
Limits and quotas
The platform limits page covers the hard limits in detail. The ones that matter most for AI Transport:
- Connection inbound message rate. A single stream that exceeds the per-connection rate triggers rate-limiting. Configure the append rollup window to control the publish rate.
- Channel message rate. Concurrent turns and multi-agent setups share the channel's rate budget.
- Message size. Large tool outputs or attachments approach the per-message size limit. Stream large results or persist them externally and reference the URL.
- Retention period. Configure your retention period through the channel rule settings. Plan for the longest gap you expect a client to replay from Ably alone.
Monitoring and observability
Watch three signals:
- Channel publish rate per conversation, against the connection's inbound rate limit.
- Pipe outcomes: resolved, rejected with
OperationCancelled, or rejected withPipeFailed. A rising failure rate is your first signal that something is wrong with model orchestration, auth, or capacity. - Server-side LLM latency and error rate, from your model provider. The Ably side is decoupled from the LLM; track them separately.
Send these signals to your existing dashboards through Ably's integrations. Webhooks, Kafka, and other sinks expose channel activity. Ably also offers Stats API for usage data.
Auth hardening
The defaults are safe for development. For production:
- Scope channel capabilities to the specific conversation channel (or a wildcard covering them) the user needs access to.
subscribeandhistoryonly on channels the user owns. - Set
clientIdin the token rather than on the client. The Ably service verifies tokens; client-set IDs are unverified and spoofable. - Use short token lifetimes and
authUrl(orauthCallback) so the SDK refreshes tokens automatically. One-hour tokens are a reasonable default. - Implement token revocation for forced sign-out.
Set up authentication covers the token endpoint, capability scoping, and the token lifecycle. The multi-device and fan-out documentation covers client identity edge cases.
Data shipping and retention periods
Your own database stores the long-term conversation history, so your retention period only has to cover the longest gap you expect a client to replay from Ably alone.
- How long the channel keeps messages depends on the channel's retention period. The channel rule persists messages for that period, and your database covers anything older.
- Store the serial that
pipe()resolves with in the same write as the response, so a client can replay the channel from exactly where your database ends. - For analytics or search, stream channel activity to your data warehouse through webhooks or Kafka. This is one-way; AI Transport reads from the channel rather than the warehouse.
Compliance
Ably is SOC 2 Type II certified and HIPAA compliant.
For the application-side:
- Message content, including tool inputs and outputs, is visible to every subscriber whose capability allows it.
- For data residency, contact Ably about a regional deployment of Ably's edge network.
Deployment notes
A few patterns that come up:
- Serverless agents are fine. Each request creates an adaptor and pipes the response. The conversation lives on the channel and in your database rather than in the agent process.
- The agent owns the realtime client it creates with
createRealtimeClient. The adaptor has noclose()and leaves the client connected, so create the client once per process and close it when the process shuts down. after()(Next.js) or equivalent post-response continuation lets the HTTP route return before the model finishes streaming. Without it, the time available for streaming is limited by the request timeout.- With
useChat:- Run the agent outside the request, so a reload does not end the response.
- An agent that listens for cancel messages on the channel should stop listening when the turn ends, because while the channel is attached, the agent receives every message on it. The agent can create a client for each turn and close the client when the turn ends, as the useChat quickstart does, or unsubscribe and detach the channel itself.
- Publish
errorfor every failure that ends a turn without afinish,abort, orerrorchunk. If the agent passes its abort signal topipe, also publishabort, because the pipe then stops beforetoUIMessageStreamwrites itsabortchunk. - If several UI message streams make up one turn, write one
startchunk and onefinishchunk for the turn, with thesendStartandsendFinishoptions oftoUIMessageStream, because astartor afinishin the middle of a turn ends the response. - Accept one turn at a time for each conversation, because the chat transport cannot differentiate two responses on one channel.
- If an agent dies mid-turn, publish
errorfor the turn, so tabs stop resuming the response. - A workflow retry after a step has started streaming ends the response in the tab, and the tab receives the retried response only after a reload.
- After a disconnection longer than about two minutes, the chat transport recovers a response that was streaming only after a reload.
- Multiple agent regions are supported. Ably's infrastructure keeps state present in every region; an agent in one region publishes and clients in any region see the same state with low latency from their nearest edge.
Durable execution
If an agent's work spans multiple stages, such as inference, tools and follow-up inference, or exceeds a serverless function's runtime budget, run the agent inside a workflow engine such as Temporal or Vercel WDK. Each stage becomes its own retryable activity, and publishes to the same channel.
Load the conversation from your database
Clients replay the channel from your database with a rewind to the stored serial. Plan for these edge cases and limits:
- Past the 1,000-message rewind limit, Ably delivers the most recent 1,000 messages, and the conversation has a gap just after the stored serial.
- History reaches back as far as your retention period.
- The channel keeps its
rewindparam. After a discontinuity, recover the conversation: unsubscribe the decoder, detach the channel, set the serial your database now holds withchannel.setOptions({ params: { rewind } }), and subscribe a new decoder, because the channel keeps its oldrewindparam. - Your agent has to be the only writer to the database clients replay from. A second writer puts messages between your stored history and the channel that the stored serial does not account for.
Read next
- Set up authentication: the token endpoint, capability scoping, and the token lifecycle.
- Platform guarantees: the platform properties AI Transport relies on.