Skip to content

fix(llm): tolerate relay keepalive events in Responses stream folding - #254

Merged
3aKHP merged 1 commit into
devfrom
fix/responses-relay-keepalive-event
Sep 18, 2026
Merged

3aKHP merged 1 commit into
devfrom
fix/responses-relay-keepalive-event

Conversation

@3aKHP

@3aKHP 3aKHP commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Problem

Second pelican test after #253 failed with Responses 流畸形:未知的语义事件 keepalive。 The relay emits keepalive SSE frames during long generations (builtin image generation in this case); the frame carries a global sequence_number (it occupies a slot in the upstream counter), but its type is unknown to the folder, so unknown-type fail-closed killed the reply.

Fix

Add keepalive to _RELAY_EVENTS — the existing home for relay-private structural events, gated behind the codex-http-relay tolerate_relay_events capability bit. Since the frame carries a proper sequence number, strict +1 validation continues seamlessly after the skip. The public profile still rejects it (official endpoints don't send it).

Tests

Two new: relay profile folds a stream with interleaved keepalives; public profile still fail-closes with 未知. Full suite 2443 passed, ruff clean.

- the relay emits keepalive frames (with global sequence numbers) during long generations such as builtin image generation; unknown-type fail-closed turned them into stream-malformed errors

- gated behind the codex-http-relay tolerate_relay_events capability bit like other relay-private structural events; public profile still rejects

@khpilot khpilot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bot Review — ✅ Approve

The PR adds keepalive to _RELAY_EVENTS so that the Responses stream folder tolerates relay-emitted keepalive SSE frames (which carry a proper sequence number) without killing the reply, while the public profile still fail-closes on unknown event types. Both reviewers completed their coverage with no blocking findings, and the fix is targeted and well-tested (relay profile passes keepalives, public profile still rejects them). Verdict: approve.

No findings reported.

Review provenance

  • General reviewer: complete — 2/2 units completed
  • Style reviewer: complete — 2/2 units completed
  • Coverage: complete
  • Reviewed head: 84ce793 (base 4bbf11f)

Automated review by @KHPilot. Reply with @KHPilot to ask follow-up questions.

@3aKHP
3aKHP merged commit 33f29e5 into dev Sep 18, 2026
4 checks passed
@3aKHP
3aKHP deleted the fix/responses-relay-keepalive-event branch September 26, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant