Skip to content

[None][chore] remove orphaned process_streaming_events helper - #16262

Merged
karljang merged 1 commit into
NVIDIA:mainfrom
lonexreb:fix/responses-empty-stream
Oct 10, 2026
Merged

karljang merged 1 commit into
NVIDIA:mainfrom
lonexreb:fix/responses-empty-stream

Conversation

@lonexreb

@lonexreb lonexreb commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Originally this PR guarded process_streaming_events against an empty stream (final_res referenced without assignment). Review asked whether a live caller exists — and the answer changed the right fix.

There is no live caller. git grep process_streaming_events across current main returns only the definition (responses_utils.py:2618). The Responses API streaming path moved to post-processors in #9908: openai_server.py constructs ResponsesStreamingProcessor per request and responses_api_streaming_post_processor (postprocess_handlers.py:1014) emits per-chunk events and builds the final event from the current GenerationResult when rsp._done — so the live path has no equivalent unbound-variable hazard, and an aborted stream simply ends the generator at the server layer.

This PR therefore now deletes the dead function instead of patching it: it is unreachable, carries a latent crash, and patching unreachable code just preserves confusion. The regression test from the earlier revision is dropped along with it (nothing left to test), which also resolves the CI-registration request.

Test Plan

  • git grep process_streaming_events → no references remain.
  • ruff (legacy config) and yapf clean on the touched file.

Dev Engineer Review

process_streaming_events was removed from tensorrt_llm/serve/responses_utils.py. The remaining ResponsesStreamingProcessor is still used by the serving code. The change removes a callable function, so downstream users that import it may need to update their code. No in-repository callers of the removed function were found.

QA Engineer Review

No test changes.

Per-File QA Perspective

  • tensorrt_llm/serve/responses_utils.py: Verify that Responses streaming still works through the ResponsesStreamingProcessor path. The removed function is no longer available to callers.

@lonexreb
lonexreb requested a review from a team as a code owner July 10, 2026 23:48
@lonexreb
lonexreb requested a review from mikeiovine July 10, 2026 23:48
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/TensorRT-LLM/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 69b4e247-6798-453e-8fd7-1bc22973a9e0
📥 Commits

Reviewing files that changed from the base of the PR and between a980a70 and 0a3f92a.

📒 Files selected for processing (1)
  • tensorrt_llm/serve/responses_utils.py
💤 Files with no reviewable changes (1)
  • tensorrt_llm/serve/responses_utils.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The public process_streaming_events async generator was removed from responses_utils.py. It previously initialized a streaming processor and yielded initial events, per-result events, and the final response.

Changes

Responses streaming utility

Layer / File(s) Summary
Remove streaming event generator
tensorrt_llm/serve/responses_utils.py
The process_streaming_events async generator and its event-yielding sequence were removed.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: bowenfu

Merge Risk: ⚪ Minimal · up to 0a3f9

The streaming endpoint does not depend on the removed helper; no actionable merge risk remains beyond normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title follows the repository’s title format and clearly identifies the removal of the unused helper.
Description check ✅ Passed The description explains why the helper is removed and includes a test plan. It omits the PR checklist, but the key change and validation are clear.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/unittest/llmapi/apps/test_responses_empty_stream.py (2)

26-49: 📐 Maintainability & Code Quality | 🔵 Trivial

No QA list update is needed.

This change only adds a narrow unit test under tests/unittest/; no integration or release schedule is affected.

As per path instructions, unittest-only changes do not require an entry under tests/integration/test_lists/qa/.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/llmapi/apps/test_responses_empty_stream.py` around lines 26 -
49, The comment confirms that no implementation change or QA list update is
required. Keep the narrow unit test
test_process_streaming_events_handles_empty_stream under tests/unittest/, and do
not add an entry under tests/integration/test_lists/qa/.

Source: Path instructions


21-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Annotate the async test helpers.

Add return annotations to _empty_stream and run to satisfy the Python typing guidelines.

Proposed fix
+from collections.abc import AsyncGenerator
+
-async def _empty_stream():
+async def _empty_stream() -> AsyncGenerator[None, None]:
     return
     yield  # pragma: no cover - makes this an async generator
...
-    async def run():
+    async def run() -> None:

As per coding guidelines, “Always annotate functions.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/llmapi/apps/test_responses_empty_stream.py` around lines 21 -
28, Add return type annotations to the async helper functions _empty_stream and
the nested run inside test_process_streaming_events_handles_empty_stream, using
the appropriate async-generator and coroutine return types consistent with their
implementations.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/unittest/llmapi/apps/test_responses_empty_stream.py`:
- Around line 26-49: The comment confirms that no implementation change or QA
list update is required. Keep the narrow unit test
test_process_streaming_events_handles_empty_stream under tests/unittest/, and do
not add an entry under tests/integration/test_lists/qa/.
- Around line 21-28: Add return type annotations to the async helper functions
_empty_stream and the nested run inside
test_process_streaming_events_handles_empty_stream, using the appropriate
async-generator and coroutine return types consistent with their
implementations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 643f0d76-2cb7-487f-b0bd-990420148a9d

📥 Commits

Reviewing files that changed from the base of the PR and between b4e7808 and a980a70.

📒 Files selected for processing (2)
  • tensorrt_llm/serve/responses_utils.py
  • tests/unittest/llmapi/apps/test_responses_empty_stream.py

@mikeiovine

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59279 [ run ] triggered by Bot. Commit: a980a70 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59279 [ run ] completed with state FAILURE. Commit: a980a70
/LLM/main/L0_MergeRequest_PR pipeline #47766 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@karljang karljang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix. Could you confirm a live caller uses this helper and whether an empty stream needs a terminal event? Please also register the regression test in CI, adding cpu_only if targeting a CPU-only stage.

process_streaming_events has had no callers since the Responses API
streaming path moved to post-processors in NVIDIA#9908: the live path drives
ResponsesStreamingProcessor directly (openai_server.py) and builds the
final event in responses_api_streaming_post_processor from the current
GenerationResult when rsp._done, so the helper's latent UnboundLocalError
on an empty stream (final_res referenced without assignment) cannot occur
there. Delete the dead function instead of patching it.

Signed-off-by: lonexreb <reach2shubhankar@gmail.com>
@lonexreb
lonexreb force-pushed the fix/responses-empty-stream branch from a980a70 to 0a3f92a Compare October 3, 2026 01:40
@lonexreb
lonexreb requested a review from a team as a code owner October 3, 2026 01:40
@lonexreb lonexreb changed the title [None][fix] handle empty stream in process_streaming_events [None][chore] remove orphaned process_streaming_events helper Oct 3, 2026
@lonexreb

lonexreb commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@karljang thanks for the pointed questions — they changed the outcome. Answers in order:

  1. Live caller: there isn't one. The only reference to process_streaming_events on current main is its definition at responses_utils.py:2618. It was orphaned when [TRTLLM-7906][feat] Support multiple post process for Responses API #9908 moved Responses streaming to the post-processor path (openai_server.py → responses_api_streaming_post_processor at postprocess_handlers.py:1014).
  2. Terminal event on empty stream: moot for this helper (dead code), and the live path doesn't have the hazard — the final event there is built from the current rsp under if rsp._done:, not from a loop variable that may never bind. Client-abort on the live path just ends the generator at the server layer.
  3. CI registration: resolved by deletion — I've repurposed the PR to remove the dead function (0a3f92a, rebased onto today's main), test dropped along with it.

If you'd rather keep the helper for some planned use, happy to revert to the guard-fix revision + register the test with cpu_only — but deleting unreachable code with a latent UnboundLocalError seemed like the better end state.

@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Oct 3, 2026

@karljang karljang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements.

@karljang

karljang commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #76492 [ run ] triggered by Bot. Commit: 0a3f92a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #76492 [ run ] completed with state FAILURE. Commit: 0a3f92a
/LLM/main/L0_MergeRequest_PR pipeline #63072 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@karljang

karljang commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77056 [ run ] triggered by Bot. Commit: 0a3f92a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77056 [ run ] completed with state SUCCESS. Commit: 0a3f92a
/LLM/main/L0_MergeRequest_PR pipeline #63523 completed with status: 'SUCCESS'

CI Report

Link to invocation

@karljang
karljang merged commit 8d9ca40 into NVIDIA:main Oct 10, 2026
JunyiXu-nv added a commit to JunyiXu-nv/TensorRT-LLM that referenced this pull request Oct 10, 2026
… paths

- A chat template is now asked whether it renders a developer message by
  rendering one, rather than by finding the word "developer" in its source.
  A template that names the role only to reject it, or mentions it in a
  comment, no longer keeps the role and loses the message. When a template
  renders neither a developer nor a system message the roles are left alone.
  Results are cached per template.
- At the end of a stream, the text the whole-text parse reads beyond the
  streamed message is released even when the parse stripped leading
  whitespace the stream already sent; a real divergence is logged instead of
  dropped silently.
- An encrypted_content part is read as text only when it is not one long
  base64 token, so a real ciphertext (OpenAI's Fernet tokens) is not put into
  the prompt.
- The unreachable storing stream finalizer (get_final_response and
  process_streaming_events, which main removed in NVIDIA#16262) is deleted, so it
  cannot be wired back in its stale form. Streamed responses are not stored.
- Generation-first scheduling of a Responses request is tested, streaming
  and not.
- The router's character-versus-token weighting is explained where it is
  computed.

Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
JunyiXu-nv added a commit to JunyiXu-nv/TensorRT-LLM that referenced this pull request Oct 10, 2026
- responses_utils.py: main removed process_streaming_events (NVIDIA#16262),
  which this branch had already deleted together with get_final_response;
  this branch's side is kept, and main's dict-shaped function_call input
  handling merged cleanly.
- release-notes.md: both new API-change entries are kept.

Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants