Skip to content

Refactor Noma guardrail to use shared Responses transformation and include system instructions - #17315

Merged
2 commits merged into
BerriAI:mainfrom
Noma-Security:NOM-6009-Support-system-prompt-in-litellm-noma-guardrail
Dec 2, 2025
Merged

2 commits merged into
BerriAI:mainfrom
Noma-Security:NOM-6009-Support-system-prompt-in-litellm-noma-guardrail

Conversation

@idola9

@idola9 idola9 commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Title

Refactor Noma guardrail to use shared Responses transformation and include system instructions

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

image
  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature
🧹 Refactoring
✅ Test

Changes

  • Aggregate system prompts in the Responses transformer itself: convert_chat_completion_messages_to_responses_api no longer overwrites instructions on each string system message; it now concatenates multiple system prompts into a single string (instructions = f"{instructions} {content}" when instructions already exists), which is then surfaced through transform_request.
  • Use shared Responses transformer in Noma guardrail: NomaGuardrail now uses LiteLLMResponsesTransformationHandler.convert_chat_completion_messages_to_responses_api instead of custom message-extraction helpers, and builds the Noma payload from input_items.
  • Forward system prompts to Noma as a single instructions message: multiple string system messages are concatenated into instructions, then turned into a single system message prepended to input before calling the Noma API; tests for single and multiple system prompts were updated accordingly.
  • Reuse transformer for image and mixed content tests: the test_extract_user_message_* and test_image_with_base64_data tests now call the transformer directly, asserting the same shapes as before (text + input_image blocks, including base64 URLs) using AllMessageValues and proper typing.

@vercel

vercel Bot commented Dec 1, 2025

Copy link
Copy Markdown

@idola9 is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@idola9 idola9 changed the title Nom 6009 support system prompt in litellm noma guardrail Refactor Noma guardrail to use shared Responses transformation and include system instructions Dec 1, 2025
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ghost
ghost merged commit 71efcb7 into BerriAI:main Dec 2, 2025
3 of 6 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…clude system instructions (BerriAI#17315)

* Support system prompts in noma guardrails

* Use litellm util to covert chat completions to responses api
This pull request was closed.
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.

2 participants