Skip to content

Comments

fix: avoid stream:false error in CodexMessageAdapter.generateResponse#511

Merged
kevin-on merged 2 commits intomainfrom
fix/codex-non-streaming-response
Jan 20, 2026
Merged

fix: avoid stream:false error in CodexMessageAdapter.generateResponse#511
kevin-on merged 2 commits intomainfrom
fix/codex-non-streaming-response

Conversation

@kevin-on
Copy link
Collaborator

@kevin-on kevin-on commented Jan 20, 2026

Description

Avoid stream:false in CodexMessageAdapter.generateResponse since Codex endpoint always requires stream:true.

Checklist before requesting a review

  • I have reviewed the guidelines for contributing to this repository.
  • I have performed a self-review of my code
  • I have performed a code linting check and type check (by running npm run lint:check and npm run type:check)
  • I have run the test suite (by running npm run test)
  • I have tested the functionality manually

Summary by CodeRabbit

  • New Features
    • Responses now stream incrementally, displaying results progressively as they arrive instead of waiting for complete response assembly.
    • Added support for non-blocking, chunked response delivery.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

The CodexMessageAdapter has been refactored to use Server-Sent Events (SSE) streaming instead of non-streaming JSON POST responses. Response objects are now assembled incrementally from streaming chunks via a new helper function that manages progressive state transitions. Final response construction extracts id, created_at, and model from the accumulated streaming payload.

Changes

Cohort / File(s) Summary
SSE Streaming Integration
src/core/llm/codexMessageAdapter.ts
Replaced non-streaming request/response flow with streaming via SSE; added accumulateResponseSnapshot helper to incrementally build Response objects from streaming events; changed final response construction to use accumulated responsePayload for id, created_at, and model; introduced separate streamResponse and streamResponseGenerator flows for chunked delivery.

Sequence Diagram

sequenceDiagram
    participant Adapter as CodexMessageAdapter
    participant SSE as SSE Stream
    participant Accumulate as accumulateResponseSnapshot
    participant Response as Response Object

    Adapter->>SSE: POST with stream: true
    Note over SSE: Streaming begins
    
    loop For each SSE event
        SSE->>Accumulate: Send ResponseStreamEvent
        activate Accumulate
        Accumulate->>Response: Mutate snapshot with delta/added
        Note over Accumulate: Handle output_item, content_part,<br/>output_text, function_call,<br/>reasoning events
        Accumulate-->>SSE: Updated snapshot
        deactivate Accumulate
    end
    
    Note over Response: Extract id, created_at, model,<br/>reasoning, tool_calls from<br/>accumulated payload
    SSE->>Adapter: Stream complete
    Adapter->>Response: Finalize response
    Adapter-->>Adapter: Return assembled Response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Streams now flow through code so bright,
Chunks arrive with SSE's might,
One by one the snapshots grow,
Building responses as they flow,
No more waiting—progress made! 🌊✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing the CodexMessageAdapter to avoid sending stream:false, which aligns with the core modification in the changeset.
Description check ✅ Passed The description includes a clear summary of the change, the motivation (Codex endpoint requires stream:true), and confirms all checklist items were completed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kevin-on kevin-on merged commit 2e3197d into main Jan 20, 2026
2 checks passed
@kevin-on kevin-on deleted the fix/codex-non-streaming-response branch January 20, 2026 04:49
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