Skip to content

feat(server): add OpenAI Chat stream projections and hooks - #2435

Open
Pouyanpi wants to merge 2 commits into
pouyanpi/transparent-proxy-streaming-kernel-1from
pouyanpi/openai-chat-streaming-contract-2
Open

Pouyanpi wants to merge 2 commits into
pouyanpi/transparent-proxy-streaming-kernel-1from
pouyanpi/openai-chat-streaming-contract-2

Conversation

@Pouyanpi

@Pouyanpi Pouyanpi commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Implements the stream surface already declared by the public OpenAI Chat guard contract, with staged projection/classifier modules and handwritten native error framing.

What Changed

  • Adds reviewed guarded-delta, metadata, provider-error, and terminal-event classifications.
  • Keeps unknown content-bearing deltas closed and choice indices strictly integer zero.
  • Tests field policy, event inventory, provenance, transport declarations, and the hook binding against the maintained guard contract.
  • Reuses the public request binding and contract without duplicating their earlier changes.

Review Notes

Review the declared event inventory, unsupported content channels, strict JSON, and native SSE error framing. Endpoint/HTTP integration lands in the final PR.

AI Assistance

  • No AI tools were used.
  • AI tools were used (Codex assisted with commit reconstruction, HTTP/error reconciliation, regression tests, and PR drafting). Human review of the new diff is pending.

Checklist

  • I've read the CONTRIBUTING guidelines.
  • This is maintainer-directed work.
  • The PR title follows the project commit convention.
  • Applicable declarations and tests are included.
  • Generated changelog files were not edited manually.
  • Automated and human review comments are addressed or answered.
  • The responsible reviewer or team is mentioned.

Stack Position

Part 2 of 4.

Stack Context

Adds OpenAI Chat streaming on top of #2414 in four independently tested slices: provider-neutral execution, OpenAI stream modules, injected HTTP lifecycle handling, and integration with the existing buffered request pipeline. Concrete outbound HTTP, deployment configuration, and replacement execution remain separate work.

Please review each PR against its parent branch, not directly against the root base branch, except for part 1.

Order PR Branch Base
1 #2434 pouyanpi/transparent-proxy-streaming-kernel-1 pouyanpi/openai-chat-buffered-integration-4
2 #2435 pouyanpi/openai-chat-streaming-contract-2 pouyanpi/transparent-proxy-streaming-kernel-1
3 #2436 pouyanpi/transparent-proxy-streaming-http-3 pouyanpi/openai-chat-streaming-contract-2
4 #2437 pouyanpi/openai-chat-streaming-integration-4 pouyanpi/transparent-proxy-streaming-http-3

@github-actions github-actions Bot added size: L status: needs triage New issues that have not yet been reviewed or categorized. labels Oct 5, 2026
@Pouyanpi
Pouyanpi force-pushed the pouyanpi/transparent-proxy-streaming-kernel-1 branch from 4ec5c7f to f4a6606 Compare October 6, 2026 11:05
@Pouyanpi
Pouyanpi force-pushed the pouyanpi/openai-chat-streaming-contract-2 branch from 73f46d5 to 625e4cb Compare October 6, 2026 11:05
@Pouyanpi Pouyanpi added this to the v0.25.0 milestone Oct 6, 2026
@Pouyanpi Pouyanpi self-assigned this Oct 6, 2026
@Pouyanpi Pouyanpi removed the status: needs triage New issues that have not yet been reviewed or categorized. label Oct 6, 2026
@Pouyanpi
Pouyanpi marked this pull request as ready for review October 6, 2026 11:06
@Pouyanpi Pouyanpi added status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). and removed status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). labels Oct 6, 2026
@Pouyanpi
Pouyanpi force-pushed the pouyanpi/openai-chat-streaming-contract-2 branch from 625e4cb to 80703c1 Compare October 6, 2026 15:22
@Pouyanpi Pouyanpi added status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). status: stale and removed status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). status: stale labels Oct 6, 2026
@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds OpenAI stream validation and projection logic.

The PR appears safe to merge; no new in-scope issue was identified, and both previous findings remain resolved.

Summary

This PR adds OpenAI Chat stream projections, event classification, terminal-state hooks, and tests aligned with the guard contract.

  • Closes unreviewed choice and delta fields while preserving declared metadata.
  • Classifies guarded text, provider errors, metadata, and the terminal sentinel.
  • Frames native SSE errors and validates stream completion.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Provider SSE event] --> B[Classify against stream projection]
  B --> C{Event role}
  C -->|Guarded text| D[Content check]
  C -->|Metadata or error| E[Stream hooks]
  D --> E
  E --> F{Valid terminal state?}
  F -->|Yes| G[Release event]
  F -->|No| H[Reject stream]
Loading

Reviews (3) · Last reviewed commit: "fix(server): validate OpenAI stream comp..." · Reviewed by Greptile

Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Reject unreviewed choice fields before releasing the original event bytes.
Regenerate the choice projection and align the maintained choice and delta
closure declarations with the inspected stream profile.

Track the actual DONE sentinel in per-stream hooks, require it for successful
completion, and reject payloads after termination. Preserve data-less keepalives
and provider-error endings with or without a final sentinel.

Cover unchecked sibling content, missing and duplicate completion, later
payloads, pending-window withholding, raw preservation, and isolated hook state.

Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
@Pouyanpi
Pouyanpi force-pushed the pouyanpi/openai-chat-streaming-contract-2 branch from c312770 to d5510f4 Compare October 7, 2026 09:00
@Pouyanpi
Pouyanpi force-pushed the pouyanpi/transparent-proxy-streaming-kernel-1 branch from 7521a53 to 9052700 Compare October 7, 2026 09:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant