Nov 2026
9 Mon
10 Tue
11 Wed
12 Thu
13 Fri 09:00 AM – 06:00 PM IST
14 Sat 09:00 AM – 06:00 PM IST
15 Sun
Aditya Singh
Submitted Sep 17, 2026
When the Client Disconnects but the Agent Keeps Running
We built a resumable streaming architecture for long-running AI agent interactions at Glance, where agent execution can continue independently of the client connection and a disconnected client can resume the stream from the last event it received.
SSE makes it straightforward to stream an LLM response to a client, but it does not solve resumability when that client disconnects mid-turn. In our architecture, that problem became more interesting because the client could reconnect to a different gateway pod while the original agent execution was still running.
We wanted to separate the gateway which owns authentication, conversation/session handling and client-facing concerns from the service running the agent. Once we did that, the lifetime of the client connection, gateway pod and agent execution were no longer the same.
A client could disconnect while an agent was still running and later reconnect to a different gateway pod. We needed to preserve the ordered history of that turn and resume from the last event the client had received, without requiring sticky sessions or coupling the agent to a particular gateway instance.
The engineering problem became less about “how do we stream tokens?” and more about where the state of an active stream should live and what exactly the unit of recovery should be.
Platform Engineering, Infrastructure, SRE, and backend developers building distributed or AI systems.
Intermediate
A production architecture story covering:
None of the alternatives were fundamentally incapable of solving the problem, but they did not fit our recovery model cleanly.
Direct SSE coupled execution and delivery too closely when the system was split across gateway and agent services.
gRPC streaming gave us a good transport between services but did not by itself provide the replayable history required when a client reconnected through another gateway pod.
Kafka provided durability and replay, but its natural recovery position is partition plus offset, whereas our application contract was turn ID plus message ID. We could have built additional indexing and cursor translation around Kafka, but that introduced considerably more machinery for the problem we were trying to solve.
We would start by defining the recovery contract rather than beginning with a transport choice.
The key questions would be:
Once those are explicit, the choice of streaming and state primitives becomes much easier.
We would also treat stream lifecycle and event granularity as first-class operational concerns from the beginning rather than as implementation details added later.
Our primary optimization was for simple per-turn recovery without pod affinity.
We considered:
Direct SSE: simplest architecture, but strongly couples the client connection to execution.
gRPC: excellent service-to-service streaming, but requires another system for replay and reconnection state.
Kafka: extremely capable for durable event streaming, but its partition-based recovery model was not naturally aligned with our per-turn addressability requirement.
Redis Streams: allowed us to give each turn its own ordered and replayable event history. A reconnecting gateway only needs the turn and the last received event ID to continue.
The trade-off is that this introduces Redis as part of the active delivery path and requires us to think about stream lifecycle, connection scale and event volume.
The main pattern is broader than Redis or even LLMs:
Choose the state model around the unit you need to recover.
Teams building agents, coding assistants, media generation pipelines or other long-running asynchronous systems often start with streaming as a transport problem. Once execution can outlive the original connection, it becomes a distributed state-management problem.
The session gives practitioners a way to reason about that transition and evaluate technologies based on their actual recovery requirements rather than simply choosing a familiar streaming system.
Production experience
#agents #platformengineering #reliability #databases #scalability #distributed-systems #casestudy
{{ gettext('Login to leave a comment') }}
{{ gettext('Post a comment…') }}{{ errorMsg }}
{{ gettext('No comments posted yet') }}