fix(sub): emit Anthropic SSE pings on quiet reroute streams - #221
Merged
Conversation
Claude Code aborts after ~180s with no downstream events ("Response
stalled mid-stream"). Sub backends often go silent while reasoning or
while tool args are buffered, which showed up as incomplete_stream with
no terminal frame at exactly three minutes. Emit event: ping every 15s
once message_start is out — on total upstream silence and on upstream
noise that produces no client-visible events. Same shape as
claude-code-proxy's historical tool-buffer keepalive.
Signed-off-by: François Kiene <46886660+fkiene@users.noreply.github.com>
fkiene
enabled auto-merge (squash)
July 26, 2026 12:05
Signed-off-by: François Kiene <46886660+fkiene@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
Response stalled mid-stream). Quiet Codex/Grok/Kimi turns (long reasoning, buffered tool-arg generation) went silent on the Anthropic side and aborted at exactly three minutes (incomplete_stream/no terminal frameinserve.log).event: pingkeepalives every 15s oncemessage_starthas been sent — both on total upstream silence (tokio::select!timer) and when upstream still sends chunks that produce no client-visible ReduceEvents (buffered tool args).is_open/emit_pingonly fire while the message is open; pings never land beforemessage_startor after close.Test plan
cargo test -p llmtrim emit_pingcargo test -p llmtrim keepalive_intervalcargo test -p llmtrim client_abort_mid_streamserve.logshould not show exactduration_ms≈180000client-abort ghosts for those turns