Repository navigation
feat(starter): send SSE heartbeat comments on streaming endpoints - #80
Merged
Merged
Conversation
Long-running agent executions leave the SSE stream silent between the
WORKING status and the terminal event, allowing intermediaries (gateways,
load balancers) to idle-timeout the connection before the result arrives.
Field logs show ~81 seconds of silence before a gateway killed the stream,
forcing the client into a polling fallback.
Add a heartbeat scheduler to the A2AController that sends a standard SSE
comment (": heartbeat") at a configurable interval on all streaming
endpoints (message:stream, tasks/{id}:subscribe). The interval defaults
to 15 seconds, matching the cadence proven by field agents that keep
their streams alive through long diagnoses. Set
a2at.server.heartbeat-interval-seconds=0 to disable.
The heartbeat integrates with the existing emitter lifecycle: it is
cancelled when the stream completes, errors, times out, or the client
disconnects, and uses a single daemon thread shared by all streams.
Signed-off-by: Zhoujie628 <zhoujie628@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Long-running agent executions leave the SSE stream silent between the WORKING status and the terminal event, allowing intermediaries (gateways, load balancers) to idle-timeout the connection before the result arrives.
Add a heartbeat scheduler to the A2AController that sends a standard SSE comment (
: heartbeat) at a configurable interval on all streaming endpoints (message:stream, tasks/{id}:subscribe). The interval defaults to 15 seconds; seta2at.server.heartbeat-interval-seconds=0to disable.The heartbeat integrates with the existing emitter lifecycle: it is cancelled when the stream completes, errors, times out, or the client disconnects, and uses a single daemon thread shared by all streams.
4 new tests: default interval, zero-disables, negative-rejects, and stream-survives-through-multiple-heartbeat-intervals.