Skip to content

fix(server): handle stop and malformed messages - #2266

Open
Pouyanpi wants to merge 2 commits into
pouyanpi/refactor-llm-call-testsfrom
pouyanpi/fix-nguard-880-stop-and-messages
Open

fix(server): handle stop and malformed messages#2266
Pouyanpi wants to merge 2 commits into
pouyanpi/refactor-llm-call-testsfrom
pouyanpi/fix-nguard-880-stop-and-messages

Conversation

@Pouyanpi

@Pouyanpi Pouyanpi commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes NGUARD-880 stop handling, streaming normalization, and malformed-message validation.

AI Assistance

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

Stack Position

Part 2 of 2.

Stack Context

Moves llm_call tests first so the NGUARD-880 fix is reviewed as a small behavioral diff.

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

Order PR Branch Base
1 #2265 pouyanpi/refactor-llm-call-tests develop
2 #2266 pouyanpi/fix-nguard-880-stop-and-messages pouyanpi/refactor-llm-call-tests

Validation

89 passed, 3 skipped
pre-commit passed

Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
@github-actions github-actions Bot added size: M status: needs triage New issues that have not yet been reviewed or categorized. labels Aug 7, 2026
@Pouyanpi
Pouyanpi marked this pull request as ready for review August 7, 2026 15:19
@Pouyanpi Pouyanpi removed the status: needs triage New issues that have not yet been reviewed or categorized. label Aug 7, 2026
@Pouyanpi Pouyanpi self-assigned this Aug 7, 2026
@Pouyanpi Pouyanpi added the status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). label Aug 7, 2026
@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes propagation of OpenAI-compatible stop parameters and adds early validation for chat messages missing a role.

  • Copies LLM parameters before extracting stop, avoiding duplicate keyword arguments and caller-owned dictionary mutation.
  • Normalizes string stop values for streaming-handler matching.
  • Rejects role-less chat messages with an OpenAI-shaped validation response.
  • Adds streaming, non-streaming, API propagation, and malformed-message regression tests.

Confidence Score: 5/5

The PR appears safe to merge with no actionable regressions identified.

The stop-parameter path now avoids duplicate arguments without mutating caller input, while malformed messages lacking roles are rejected before rails initialization.

Important Files Changed

Filename Overview
nemoguardrails/llm/call.py Safely extracts stop parameters from a copied options dictionary and normalizes streaming-handler stop state.
nemoguardrails/server/schemas/openai.py Adds permissive message-object validation that requires a string role while preserving extra OpenAI-compatible fields.
tests/llm/test_call.py Covers stop precedence, input immutability, and streaming normalization across string, list, and null values.
tests/server/test_api.py Covers malformed-message rejection and propagation of supported stop values into generation options.

Reviews (1): Last reviewed commit: "fix(streaming): normalize string stop se..." | Re-trigger Greptile

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

Labels

size: M 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.

2 participants