CSE Roadmap

Common tier · about 3 hours · 12 parts

Part 4 of 12 · 1 min read

Silence looks like death to a proxy

A connection that goes quiet gets cut, even though the agent is still working.

Think of a phone call that goes quiet. After enough silence, the person on the other end assumes the line dropped and hangs up, even if you were just thinking.

In plain words: a proxy that sees no traffic for too long assumes the connection is dead and closes it, so a slow but alive agent step can get cut off from underneath.

A worked example. A proxy closes any connection idle for more than 60 seconds. A tool call keeps the stream silent from second 4 to second 95. Without anything to break that silence, the connection is closed at second 64 — the tool call never gets to finish. Sending a small heartbeat comment every 15 seconds keeps traffic flowing, and the connection is never closed by the idle timeout.

The key lines.

# from code/mini-stream/sse.py
def proxy_killed(event_times, idle_timeout):
    t = sorted(event_times)
    last = 0.0
    for x in t + [t[-1] if t else 0]:
        if x - last > idle_timeout: return last + idle_timeout
        last = x
    return None

Read it as: walk through the event times in order. If the gap since the last one ever exceeds the timeout, that is when the proxy would cut the connection. A heartbeat just has to arrive more often than the shortest idle timeout anywhere on the path. The heartbeat is HEARTBEAT = ": keep-alive\n\n". It is a comment line that clients ignore, but it still counts as traffic.

Heartbeat

A small, meaningless message sent on a schedule purely to keep a connection from looking idle.

Example: a : keep-alive comment line every 15 seconds, well under the proxy's 60-second idle timeout.