feat(ai-guard): apply sensitive data redaction from evaluate responses - #12394
feat(ai-guard): apply sensitive data redaction from evaluate responses#12394manuel-alvarez-alvarez wants to merge 2 commits into
Conversation
120a7e9 to
49d1167
Compare
There was a problem hiding this comment.
An enabled redaction request that fails before response processing has no redaction tag on its span or error metric. The missing tag makes the request look like the kill switch is off.
🤖 Datadog Autotest · Commit 49d1167 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49d1167c8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This comment has been minimized.
This comment has been minimized.
| return AIGuardRedaction.DISABLED; | ||
| } | ||
| span.setTag(REDACTED_TAG, redaction.redacted()); | ||
| if (redaction.skipped > 0) { |
There was a problem hiding this comment.
I think we should also report redaction_error telemetry on failure
There was a problem hiding this comment.
Where is it defined in the RFC? (I couldn't find it 😓)
There was a problem hiding this comment.
I was mentioned on the tracer recommended behavior
If two entries for the same path carry different replacement values (a backend bug), the tracer skips that path and records a telemetry error rather than guessing
But not listed on telemetry part.
There was a problem hiding this comment.
Can we update the RFC or add and addendum?, just to set redaction_error as the tag for this particular case
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
What Does This Do
/evaluateresponses may now carry a top-levelredaction_replacementsarray of{path, replacement}entries. Its presence is the signal to redact — there is no separate flag. The service returns the fully redacted string per path, so the tracer resolves the path and overwrites that one string verbatim: no offsets, no encodings, no merging.Evaluation.getMessages()returns the evaluated messages, redacted when redaction was applied;getRedactionReplacements()reports what was applied. Callers should forwardgetMessages()to their LLM provider.AIGuardAbortErrordeliberately carries no messages.DD_AI_GUARD_REDACTION_ENABLED(defaulttrue) is a kill switch, checked before any redaction work.ai_guard.redactedspan tag and aredactedtag on theai_guard.requeststelemetry metric. Both are omitted entirely when the kill switch is off, so an absent tag means "redaction is off" and stays distinguishable fromfalse.Redaction is applied copy-on-write — the caller's list is never mutated, only redacted messages are rebuilt, and the same list reference is returned when nothing changed. Unresolvable paths, non-string targets, and missing or conflicting replacements are skipped fail-safe and counted, never raised.
Motivation
Until now, AI Guard's backend applies a Sensitive Data Scanner (SDS) and returns matches in the sds_findings field of its API response. Those matches are purely informative today: they are surfaced through the SDK and presented in the UI, but nothing is transformed.
This PR extends that capability to sensitive data redaction. Sensitive data is removed from LLM interactions (before a prompt reaches the provider, and on the provider's responses), and the same redaction is applied to the data sent to the backend for use in the UI.
Additional Notes
Implements the tracer side of the AI Guard Sensitive Data Redaction RFC.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueAPPSEC-69390