Skip to content

FIX: keep prompt text after </document> in PromptShieldTarget parser - #2838

Open
Manohar Paturi (ManoharPaturi) wants to merge 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/prompt-shield-document-parsing
Open

Manohar Paturi (ManoharPaturi) wants to merge 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/prompt-shield-document-parsing

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Fixes #2837.

the parser now appends the text after each closing tag to the userPrompt instead of discarding it, so trailing and between-document text reaches the jailbreak scan.

3 new tests cover text between documents, trailing text after the last document, and the docstring example unchanged. all fail on main and pass here. shield target suite 15/15 green, ruff clean.

The document parser sent only text before the first <document> tag as the
userPrompt. Anything after a closing </document> tag, including text between
two documents and the tail of the prompt, was silently dropped from the
request sent to the Prompt Shield endpoint, so that part of the user prompt
was never scanned for jailbreak detection. Append the post-close text to the
userPrompt instead.
Copilot AI balanced review requested due to automatic review settings September 25, 2026 16:10

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

PromptShieldTarget drops prompt text after each </document> tag

2 participants