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 clientId and use it on every device. A user who joins from their phone and laptop with a different clientId counts 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-clientType claim with the value server.

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 with PipeFailed. 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. subscribe and history only on channels the user owns.
  • Set clientId in 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 (or authCallback) 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 no close() 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 error for every failure that ends a turn without a finish, abort, or error chunk. If the agent passes its abort signal to pipe, also publish abort, because the pipe then stops before toUIMessageStream writes its abort chunk.
    • If several UI message streams make up one turn, write one start chunk and one finish chunk for the turn, with the sendStart and sendFinish options of toUIMessageStream, because a start or a finish in 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 error for 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 rewind param. After a discontinuity, recover the conversation: unsubscribe the decoder, detach the channel, set the serial your database now holds with channel.setOptions({ params: { rewind } }), and subscribe a new decoder, because the channel keeps its old rewind param.
  • 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.