fix: correct Amazon Comprehend PII masking docs [closes DOC-1120] - #4006
Merged
Lauren Hirata Singh (lnhsingh) merged 2 commits intoAug 25, 2026
Merged
Conversation
- Replace fictitious comprehend.batch_detect_pii_entities with a recursive walk that calls the real detect_pii_entities API. AWS Comprehend does not expose a batch PII endpoint; batch_detect_entities returns generic entities (not PII). - Recurse over the full input/output payload so PII is scrubbed across spans of every shape, not just chat-completion shaped ones. - Add a Warning callout documenting the lack of a batch PII API and pointing to start_pii_entities_detection_job for true bulk workloads. - Add a short section showing how to plug Comprehend into the existing create_anonymizer helper for use with langchain agent middleware. Co-authored-by: Kathryn May <44557882+katmayb@users.noreply.github.com>
Collaborator
|
Copilot resolve the merge conflicts in this pull request |
Co-authored-by: lnhsingh <15386648+lnhsingh@users.noreply.github.com>
Contributor
Resolved the merge conflict and merged |
Lauren Hirata Singh (lnhsingh)
marked this pull request as ready for review
August 25, 2026 16:13
github-actions
Bot
requested review from
Florence Morris (fjmorris) and
Kathryn May (katmayb)
August 25, 2026 16:13
Contributor
|
Mintlify preview branch generated: Site preview: https://langchain-5e9cc07a-preview-opensw-1787674483-6bd21af.mintlify.site Important Preview links may take a few minutes to start working while the deployment finishes. Changed documentation pages (preview deep links): |
Lauren Hirata Singh (lnhsingh)
deleted the
open-swe/doc-1120-comprehend-pii
branch
August 25, 2026 16:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Amazon Comprehend section of
/langsmith/mask-inputs-outputsreferencedcomprehend.batch_detect_pii_entities, which does not exist in boto3 (and the linked AWS reference page wasAPI_BatchDetectEntities, a generic-entity API, not a PII API). The per-runcomprehend_anonymizeexample also only inspecteddata['messages']ordata['choices'][0]['message'], so PII slipped through for any run whose payload didn't match that exact shape (tool calls, retrievers, custom run types, etc.).This PR rewrites both examples to recurse over the full payload and call the real
detect_pii_entitiesAPI (with a per-flush dedupe cache in the batch example), adds a Warning callout explaining the lack of a Comprehend batch PII endpoint, and adds a short example showing how to wire Comprehend intocreate_anonymizerfor use with LangChain agent middleware.Release Note
none
Test Plan
Opened collaboratively by Kathryn May and open-swe.