Repository navigation
fix(chat): relay translated heartbeats #5806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
22 changes: 22 additions & 0 deletions
22
structure/decisions/ADR-5805-chat-completions-heartbeat-relay.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # ADR-5805 — decision recorded under "Heartbeat and stall deadline" | ||
|
|
||
| - Contract owner: [transports/streaming-health.md](../transports/streaming-health.md#heartbeat-and-stall-deadline) | ||
|
|
||
| ## Decision record | ||
|
|
||
| - Purpose and intent: Keep translated Chat Completions streams transport-alive while the Responses bridge | ||
| is receiving typed heartbeats during long reasoning or held output. | ||
| - Existing behavior and constraints: The converter used a heartbeat only to ensure the initial assistant role; | ||
| every later heartbeat produced no downstream byte. A keepalive must remain valid SSE, preserve | ||
| backpressure and translator accounting, and must not look like model content or tool progress. | ||
| - Alternatives considered: Drop typed heartbeats; emit an empty `chat.completion.chunk`; emit an SSE | ||
| comment; add a separate nonstandard Chat event type. | ||
| - Chosen approach: Emit one bounded `: opencodex heartbeat` SSE comment for each typed Responses | ||
| heartbeat after ensuring the initial role chunk. | ||
| - Why this approach: SSE comments refresh transport-idle timers while every | ||
| compliant event parser discards them. Empty or nonstandard data events can be miscounted as | ||
| semantic output and would widen the Chat wire contract. | ||
| - Benefits, drawbacks, and impact: Long silent Chat translations now deliver regular transport bytes without | ||
| changing content, tools, usage, terminal behavior, cancellation, or upstream stall detection. A | ||
| client's separate semantic-progress watchdog may still expire, which is intentional because a | ||
| keepalive proves connection liveness rather than model progress. |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 28944
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 31648
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 38228
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 37357
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 42138
Do not fail the stream when a heartbeat reservation is temporarily unavailable.
The heartbeat is processed while the decoder still charges the current input record. If fewer than 23 bytes remain,
enqueueLiveFramethrows before that record is released. The converter then returns a 502, even though the decoder would release the record before the terminal Chat batch, which can still fit. Drop only this transport heartbeat on budget overflow. Preserve failures for semantic frames.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents