Repository navigation
fix(auditlog-ng): strip prompt/response text from AiMessageContext - #450
Merged
LucasAlvesSoares merged 5 commits intoNov 5, 2026
Merged
LucasAlvesSoares merged 5 commits into
LucasAlvesSoares merged 5 commits into
Conversation
Several AI audit events embed an AiMessageContext whose prompt_text and response_text fields hold the verbatim model input/output and may contain sensitive data. Strip those two fields centrally in AuditClient.send() before validation and serialization, so no current or future event type forwards that content to the audit log. Correlation fields (uid, name, ai_role_id) and token counts are preserved. Events without a message_context field, or with an unset one, are left untouched.
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
Several AI audit events (
AiPromptReceived,AiGuardrailTriggered,AiModelInvocation,AiResponseGenerated,AiMessageSent,AiTaskCreated,AiTaskUpdated,AiUserInputRequested,AiTurnStart,AiTurnEnd) embed anAiMessageContext(proto fieldmessage_context). Two of its fields —prompt_textandresponse_text— hold the verbatim model input/output and are flagged in the proto as "may contain sensitive data".This change strips those two free-text fields centrally in
AuditClient.send(), before validation and serialization, so that no event type forwards the raw prompt/response content to the audit log — current or future.Correlation fields (
uid,name,ai_role_id) and the token counts (prompt_tokens,completion_tokens,total_tokens) are preserved, so events remain useful for correlation and metrics. Events without amessage_contextfield, or with an unset one, are left untouched (the helper guards withHasFieldso it never auto-creates an empty sub-message).Related Issue
Type of Change
How to Test
send()).prompt_textandresponse_textare empty;uidand token counts are retained.Automated tests:
All 31 tests pass (5 new in
TestStripMessageContextText, covering stripping, field preservation, unset contexts, events without the field, and end-to-end viasend()).Checklist
/security-reviewand addressed all findingsBreaking Changes
None. The stripped fields are optional and were never required for a valid event. Callers that set
prompt_text/response_textwill simply find them absent in the emitted record; all other fields are unaffected.Additional Notes
The scrubbing is enforced unconditionally in the single
send()choke point rather than per-event, so any AI event type added later is covered automatically without further changes.