Skip to content

Fix/prompt shield parser - #2885

Closed
Joel (aspire488) wants to merge 2 commits into
microsoft:mainfrom
aspire488:fix/prompt-shield-parser
Closed

Joel (aspire488) wants to merge 2 commits into
microsoft:mainfrom
aspire488:fix/prompt-shield-parser

Conversation

@aspire488

Copy link
Copy Markdown
Contributor

Description

Tests and Documentation

Description

Fixes #2837.

PromptShieldTarget._input_parser currently drops text that appears after a closing </document> tag. This means text between documents and text after the final document can be silently omitted from the userPrompt sent to Azure Prompt Shield.

For example:

q1 <document> d1 </document> q2 <document> d2 </document> q3

was parsed without q2 and q3.

Changes

  • Preserve text following each closing </document> tag.
  • Keep document extraction behavior unchanged.
  • Add regression coverage for multiple documents with text between and after them.

Testing

Added focused unit coverage for the reported reproduction.

No live Azure Prompt Shield or external service calls were performed.

Closes #2837.

@romanlutz

Copy link
Copy Markdown
Contributor

Thanks for the fix. I am closing this as a duplicate of #2838, which was opened first and addresses the same Prompt Shield parsing bug in #2837. Let us continue the fix and review there.

@aspire488

Copy link
Copy Markdown
Contributor Author

Thanks for the fix. I am closing this as a duplicate of #2838, which was opened first and addresses the same Prompt Shield parsing bug in #2837. Let us continue the fix and review there.

Thanks Roman, understood.

I’ll continue the fix and review on #2838 instead. Thanks for pointing me to the earlier PR.

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