Skip to content

refactor(llmrails): extract streaming workflow (5/9)#2127

Draft
Pouyanpi wants to merge 1 commit into
restack/llmrails-04-generationfrom
restack/llmrails-05-streaming
Draft

refactor(llmrails): extract streaming workflow (5/9)#2127
Pouyanpi wants to merge 1 commit into
restack/llmrails-04-generationfrom
restack/llmrails-05-streaming

Conversation

@Pouyanpi

@Pouyanpi Pouyanpi commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Description

Moves streaming task lifecycle and streaming output-rail execution into focused helpers.

Why

Streaming behavior becomes separate from standard generation and can be reviewed and tested on its own.

What Changed

  • Extracts stream task lifecycle and output-rail orchestration.
  • Delegates stream_async and the private compatibility wrapper.
  • Preserves current develop user-content resolution and per-chunk action-parameter isolation.
  • Adds focused streaming lifecycle and rail tests.

Review Guidance

Use the LLMRails decomposition review matrix to validate streaming, metadata, cancellation, buffering, and output-rail scenarios against the recorded #2122 baseline.

Focus on cancellation, end-of-stream behavior, output-rail sequencing, and compatibility wrappers. The policy changes intentionally excluded from this extraction are isolated in part 9.

This nine-part stack turns LLMRails into a public compatibility shell while moving owned behavior into focused modules. Review each PR only against its parent. Parts 2-6 intentionally stage behavior-preserving extraction; part 7 consolidates shared type contracts and logger naming; part 8 establishes the final package ownership; part 9 contains the explicit semantic follow-ups.

For parts 2-6, please distinguish stack-local correctness or compatibility problems from naming and placement concerns already resolved in parts 7-8. If an intermediate name or location is correct and mergeable at that point, prefer reviewing its final form in the resolving PR instead of requesting duplicate churn. Public API changes, behavior changes, import cycles, or an independently broken intermediate branch remain in scope wherever they appear. Much of the apparent added LOC is moved code plus focused tests; the corresponding implementation is removed or delegated from llmrails.py in the same PR.

Stack Position

Part 5 of 9.

Order PR Branch Base
1 #2123 restack/llmrails-01-public-contract-tests develop
2 #2124 restack/llmrails-02-startup restack/llmrails-01-public-contract-tests
3 #2125 restack/llmrails-03-runtime-conversation restack/llmrails-02-startup
4 #2126 restack/llmrails-04-generation restack/llmrails-03-runtime-conversation
5 #2127 restack/llmrails-05-streaming restack/llmrails-04-generation
6 #2128 restack/llmrails-06-checks-final restack/llmrails-05-streaming
7 #2129 restack/llmrails-07-consistency restack/llmrails-06-checks-final
8 #2130 restack/llmrails-08-boundary-ownership restack/llmrails-07-consistency
9 #2131 restack/llmrails-09-followups restack/llmrails-08-boundary-ownership

Verification

make test
poetry run pre-commit run --all-files

Rebase checkpoints: stack 2: 5202 passed, 178 skipped; stack 4: 5263 passed, 178 skipped; stack 5: 5284 passed, 178 skipped; final stack: 5320 passed, 178 skipped. Final pre-commit: all hooks passed. Base: develop at 3fc828b7f.

AI Assistance

  • No AI tools were used.
  • AI tools were used; a human reviewed and can explain every change (tool: Codex).

Checklist

  • I've read the CONTRIBUTING guidelines.
  • This PR links to a triaged issue assigned to me.
  • My PR title follows the project commit convention.
  • I've updated the documentation if applicable.
  • I've added tests if applicable.
  • I've noted any verification beyond CI and any checks I couldn't run.
  • I did not update generated changelog files manually.
  • I addressed all CodeRabbit, Greptile, and other review comments, or replied with why no change is needed.
  • @mentions of the person or team responsible for reviewing proposed changes.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ails/rails/llm/streaming/streaming_output_rails.py 96.87% 4 Missing ⚠️
nemoguardrails/rails/llm/llmrails.py 77.77% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Pouyanpi Pouyanpi removed the status: needs triage New issues that have not yet been reviewed or categorized. label Jul 2, 2026
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.

1 participant