Skip to content

Revert "Fix: /openai/<chat_id>/chat/completions not aware of session_id" - #15205

Merged
wangq8 merged 1 commit into
mainfrom
revert-15155-bugfix/fix-openapi-chat-not-aware-session_id
May 25, 2026
Merged

wangq8 merged 1 commit into
mainfrom
revert-15155-bugfix/fix-openapi-chat-not-aware-session_id

Conversation

@wangq8

@wangq8 wangq8 commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Reverts #15155 because this is never supported, keep it as it is.

@coderabbitai

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b520cabe-01db-4b22-bc7e-13f8dfe4f216

📥 Commits

Reviewing files that changed from the base of the PR and between f8c626b and 35fce49.

📒 Files selected for processing (2)
  • api/apps/restful_apis/openai_api.py
  • test/testcases/restful_api/test_openai_compatible.py

📝 Walkthrough

Walkthrough

The OpenAI-compatible chat completions endpoint is refactored to eliminate session and conversation persistence. Session parameters are no longer accepted or validated. Messages are built through direct filtering instead of helper functions. Both streaming and non-streaming paths remove conversation restructuring. The response no longer includes session_id. Tests are updated to cover reference metadata output and streaming semantics.

Changes

Session-free OpenAI Chat Completions

Layer / File(s) Summary
Session infrastructure cleanup
api/apps/restful_apis/openai_api.py
Import adjustments remove conversation-related dependencies; helper functions _build_chat_messages and _prepare_session are deleted; session_id parameter validation code removed.
Message preparation refactor
api/apps/restful_apis/openai_api.py
Message list is now constructed via direct filtering (skip system, skip leading assistant) instead of calling conversation-backed helpers.
Streaming path sessionless operation
api/apps/restful_apis/openai_api.py
async_chat call updated to exclude conversation inputs and conditionally include doc_ids; SSE event assembly removes conversation restructuring while preserving delta.final_content and reference metadata handling.
Non-streaming path sessionless operation
api/apps/restful_apis/openai_api.py
Direct consumption of first async_chat result replaces conversation persistence; session_id no longer conditionally added to response JSON.
Test coverage alignment
test/testcases/restful_api/test_openai_compatible.py
Tests for session_id support removed; new tests added for non-stream reference output shape, SSE stream [DONE] termination and chunk semantics, and reference_metadata array field filtering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#14380: Introduced the /openai/<chat_id>/chat/completions endpoint; this PR removes session/conversation handling from that same handler.
  • infiniflow/ragflow#15155: Added session_id support and session-aware response structuring to the OpenAI chat completions endpoint; this PR reverses those changes by removing all session/conversation persistence.

Suggested labels

ci, size:XS

Suggested reviewers

  • buua436

Poem

🐰 Conversations fade to whispers in the wind,
Sessions shed like autumn leaves—
Now messages flow pure and unadorned,
No stored shadows on the stone.
Simpler streams, cleaner dreams! ✨


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.

@wangq8
wangq8 marked this pull request as ready for review May 25, 2026 06:22
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 25, 2026
@wangq8
wangq8 merged commit bb148ed into main May 25, 2026
6 checks passed
@yingfeng
yingfeng deleted the revert-15155-bugfix/fix-openapi-chat-not-aware-session_id branch May 25, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant