:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(aio): show a placeholder for SDK-redacted media in traces (#88278)
Carlos Marchal68715e6685ac
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex b88773d87ad1..321fe940941a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5544,6 +5544,18 @@ snapshots:hash: v1.k794b7964.5cdaae6b72efa77261704903c3b14197bd4996f9db290718a4a585758aaa6cf2.xbF6ujFL2OI5SqKxuBM4wYp4MT4t2IC_HjI5-9mkT4cscenes-app-ai-observability-prompts--prompts-list--light:hash: v1.k794b7964.f4a3e9e0c94c327fbf41ea4698bb4d9cb92b5112848b3ee7f31c57466f0075b2.MoyySImBvALTiYl2FHqO1UG4XLCdcaJJzoUG56t_7gI+ scenes-app-ai-observability-redacted-media-placeholder--audio--dark:+ hash: v1.k794b7964.033a00b2dba30f23eb78439e091493ce9882d8e93bf3931b74c06a2b3baa8bdc.q2eqo0JCAfpaZw91QmzH16t5IDUxFvwzXGHrvliQg5c+ scenes-app-ai-observability-redacted-media-placeholder--audio--light:+ hash: v1.k794b7964.1f6f1b3393b7c81370811d174b4e4be2d15ffb4ea05cb1f520ae5f3f51db480b.E0iutulZCgpw_CjBq9e3v21MEgZAHq9ItfT_rrGCMXU+ scenes-app-ai-observability-redacted-media-placeholder--file--dark:+ hash: v1.k794b7964.e44b97723e4a306b6efe828d965f5bf92cdea10a813747631492ad5878edd609.BKJYx84LCaCubTyfk6jBP1ntA5XR2t4ZEVcbi7aoIgI+ scenes-app-ai-observability-redacted-media-placeholder--file--light:+ hash: v1.k794b7964.66dffafc8d3bc8beda0089977a92437f09c92f20f796af7abbe1a9415484c41e.q_20mytUBABuA-EIIxCF0yqBXbklK1hyro1K7VEc6UU+ scenes-app-ai-observability-redacted-media-placeholder--image--dark:+ hash: v1.k794b7964.600a87118accb7b93bef8591fb8ea95232f457c2a6c89d101bc536a39454e307.M_0N_XTHy_DrANm8eNM0scyzCQapj-gyWVp09OwRj3I+ scenes-app-ai-observability-redacted-media-placeholder--image--light:+ hash: v1.k794b7964.79d952276af1610b08389fad8cbed951da9a6d9943727fdaf7958d565694f747.vhVcjG9Vo1GI6vXuPGPxrdS8f-uccR3Pa-z2YxEK-M4scenes-app-ai-observability-self-driving-signal-source-toggle--load-failed--dark:hash: v1.k794b7964.594419147aefa58da5dddcb6b52c77c2f0c89f4830115a85cb93be8a719cfcc3.-0XtR5ua7OLwsi_LNT4ez5y9XsLqX4eQLrRsOX25y9Uscenes-app-ai-observability-self-driving-signal-source-toggle--load-failed--light:diff --git a/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsx b/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsxindex 146e90ecd2fa..95be1cfce4e3 100644--- a/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsx+++ b/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsx@@ -5,7 +5,7 @@ import { Provider } from 'kea'import { initKeaTests } from '~/test/init'-import { CompatMessage } from '../types'+import { CompatMessage, MultiModalContentItem } from '../types'import {ConversationDisplayOption,ConversationMessagesDisplay,@@ -136,6 +136,60 @@ describe('LLMMessageDisplay', () => {expect(container.querySelector('img')?.getAttribute('src')).toBe(expectedSrc)})+ it('replaces a redacted sentinel reaching the JSON-string image path with a placeholder', () => {+ const message: CompatMessage = {+ role: 'assistant',+ content: JSON.stringify({ type: 'image', content: { type: 'image', image: '[base64 image redacted]' } }),+ }+ const { container } = render(+ <Provider>+ <LLMMessageDisplay message={message} show />+ </Provider>+ )++ expect(container.querySelector('img')).toBeNull()+ expect(container.querySelector('[data-attr="ai-message-redacted-media"]')).not.toBeNull()+ })++ it('keeps the transcript when redacted audio replaces the player', () => {+ const message: CompatMessage = {+ role: 'user',+ content: [+ {+ type: 'audio',+ data: '[base64 audio redacted]',+ transcript: 'a spoken sentence',+ id: 'aud_1',+ expires_at: 0,+ },+ ],+ }+ const { container } = render(+ <Provider>+ <LLMMessageDisplay message={message} show />+ </Provider>+ )++ expect(container.querySelector('audio')).toBeNull()+ expect(container.querySelector('[data-attr="ai-message-redacted-media"]')).not.toBeNull()+ expect(screen.getByText('a spoken sentence')).toBeInTheDocument()+ })++ it('keeps the filename when a redacted file replaces the download link', () => {+ const message: CompatMessage = {+ role: 'user',+ content: [{ type: 'file', file: { file_data: '[base64 file redacted]', filename: 'doc.pdf' } }],+ }+ const { container } = render(+ <Provider>+ <LLMMessageDisplay message={message} show />+ </Provider>+ )++ expect(container.querySelector('[data-attr="ai-message-redacted-media"]')).not.toBeNull()+ expect(screen.getByText('doc.pdf')).toBeInTheDocument()+ })+it('renders OpenAI Responses input_text/input_image content parts as text and an image', () => {const dataUri = 'data:image/jpeg;base64,/9j/4AAQSkZ'const message: CompatMessage = {@@ -452,4 +506,77 @@ describe('ImageMessageDisplay', () => {expect(image).not.toBeNull()expect(image).toHaveAttribute('data-attr', 'ai-message-image')})++ const REDACTED = '[base64 image redacted]'+ const redactedParts: [string, MultiModalContentItem, string][] = [+ ['python image sentinel', { type: 'image_url', image_url: { url: REDACTED } }, 'Image'],+ ['node image sentinel', { type: 'image_url', image_url: { url: '[base64 image/png redacted]' } }, 'Image'],+ ['data-uri-wrapped sentinel', { type: 'image_url', image_url: { url: `data:;base64,${REDACTED}` } }, 'Image'],+ ['vercel image sentinel', { type: 'image', image: REDACTED }, 'Image'],+ ['input_image sentinel', { type: 'input_image', image_url: REDACTED }, 'Image'],+ [+ 'anthropic image sentinel',+ { type: 'image', source: { type: 'base64', media_type: 'image/png', data: REDACTED } },+ 'Image',+ ],+ [+ 'gemini snake_case image sentinel',+ { type: 'image', inline_data: { mime_type: 'image/png', data: REDACTED } },+ 'Image',+ ],+ [+ 'gemini camelCase image sentinel',+ { type: 'image', inlineData: { mimeType: 'image/png', data: REDACTED } },+ 'Image',+ ],+ ['file sentinel', { type: 'file', file: { file_data: '[base64 file redacted]', filename: 'doc.pdf' } }, 'File'],+ [+ 'anthropic document sentinel',+ { type: 'document', source: { type: 'base64', media_type: 'application/pdf', data: REDACTED } },+ 'File',+ ],+ [+ 'gemini document sentinel',+ { type: 'document', inline_data: { mime_type: 'application/pdf', data: REDACTED } },+ 'File',+ ],+ [+ 'audio sentinel',+ { type: 'audio', data: '[base64 audio redacted]', transcript: '', id: 'aud_1', expires_at: 0 },+ 'Audio',+ ],+ ]++ it.each(redactedParts)('replaces %s with a placeholder instead of a broken media element', (_name, part, label) => {+ const message: CompatMessage = { role: 'user', content: [part] }+ const { container } = render(+ <Provider>+ <LLMMessageDisplay message={message} show />+ </Provider>+ )++ expect(container.querySelector('img')).toBeNull()+ expect(container.querySelector('[data-attr="ai-message-redacted-media"]')).not.toBeNull()+ expect(screen.getByText(`${label} not captured.`)).toBeInTheDocument()+ expect(screen.getByRole('link')).toHaveAttribute(+ 'href',+ 'https://posthog.com/docs/ai-observability/large-events'+ )+ })++ it.each([+ ['inline data uri', 'data:image/png;base64,iVBORw0KGgo='],+ ['offloaded blob pointer', `phaiblob://v1/sha256/${'a'.repeat(64)}?mime=image%2Fpng&size=131072`],+ ['plain remote https url', 'https://example.com/a.png'],+ ])('keeps rendering an image for %s', (_name, url) => {+ const message: CompatMessage = { role: 'user', content: [{ type: 'image_url', image_url: { url } }] }+ const { container } = render(+ <Provider>+ <LLMMessageDisplay message={message} show />+ </Provider>+ )++ expect(container.querySelector('img')).not.toBeNull()+ expect(container.querySelector('[data-attr="ai-message-redacted-media"]')).toBeNull()+ })})diff --git a/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.tsx b/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.tsxindex 443af0bbe3e7..876422802f56 100644--- a/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.tsx+++ b/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.tsx@@ -16,6 +16,7 @@ import { aiBlobRenderHandlers, resolveAiBlobUrl, resolveDataUri } from '../aiBloimport { getJsonContainerForDisplay, JSONValueDisplay } from '../components/JSONValueDisplay'import { MessageSentimentBar } from '../components/SentimentTag'import { LLMInputOutput } from '../LLMInputOutput'+import { isRenderableMediaSource, redactedMediaKind } from '../mediaSource'import { SearchHighlight } from '../SearchHighlight'import { containsSearchQuery } from '../searchUtils'import type { GenerationSentiment } from '../sentimentResults'@@ -37,6 +38,7 @@ import {import { HighlightedLemonMarkdown } from './HighlightedLemonMarkdown'import { HighlightedXMLViewer } from './HighlightedXMLViewer'import { MessageActionsMenu } from './MessageActionsMenu'+import { RedactedMediaPlaceholder } from './RedactedMediaPlaceholder'import { XMLViewer } from './XMLViewer'export type ConversationDisplayOption =@@ -386,6 +388,9 @@ export const ImageMessageDisplay = ({ message }: { message: ImageDisplayMessageif (typeof content === 'string') {return <span>{content}</span>} else if (content?.image) {+ if (!isRenderableMediaSource(content.image)) {+ return <RedactedMediaPlaceholder kind="image" />+ }const src = resolveAiBlobUrl(content.image, currentTeamId)return (<img src={src} alt="User sent image" data-attr="ai-message-image" {...aiBlobRenderHandlers(src, 'image')} />@@ -408,6 +413,13 @@ function renderContentItem()}+ // File and audio parts carry a filename or transcript alongside the payload, so those kinds are+ // replaced inside their own branch to keep that content. An image part is only the image.+ const redacted = redactedMediaKind(item)+ if (redacted === 'image') {+ return <RedactedMediaPlaceholder kind="image" />+ }+if (!item || typeof item !== 'object' || !('type' in item)) {return <HighlightedJSONViewer src={item} name={null} collapsed={5} searchQuery={searchQuery} />}@@ -476,6 +488,9 @@ function renderContentItem(}if (isOpenAIFileMessage(item)) {+ if (redacted === 'file') {+ return <RedactedMediaPlaceholder kind="file" filename={item.file.filename} />+ }const resolved = resolveAiBlobUrl(item.file.file_data, currentTeamId)if (resolved === item.file.file_data && !item.file.file_data.startsWith('data:')) {return <span className="text-muted">{item.file.filename}</span>@@ -489,6 +504,9 @@ function renderContentItem(}if (isAnthropicDocumentMessage(item)) {+ if (redacted === 'file') {+ return <RedactedMediaPlaceholder kind="file" />+ }const href = resolveDataUri(item.source.data, item.source.media_type, currentTeamId)const fileName = `document.${item.source.media_type.split('/')[1] || 'bin'}`return (@@ -500,6 +518,9 @@ function renderContentItem(}if (isGeminiDocumentMessage(item)) {+ if (redacted === 'file') {+ return <RedactedMediaPlaceholder kind="file" />+ }const inlineData = getGeminiInlineData(item)if (!inlineData) {return null@@ -521,7 +542,11 @@ function renderContentItem(return (<div className="space-y-2">- <audio controls className="w-[500px]" src={src} {...aiBlobRenderHandlers(src, 'audio')} />+ {redacted === 'audio' ? (+ <RedactedMediaPlaceholder kind="audio" />+ ) : (+ <audio controls className="w-[500px]" src={src} {...aiBlobRenderHandlers(src, 'audio')} />+ )}{transcript && typeof transcript === 'string' && (<div className="text-xs text-muted p-2 bg-bg-light rounded border"><div className="font-semibold mb-1">Transcript:</div>diff --git a/products/ai_observability/frontend/ConversationDisplay/RedactedMediaPlaceholder.stories.tsx b/products/ai_observability/frontend/ConversationDisplay/RedactedMediaPlaceholder.stories.tsxnew file mode 100644index 000000000000..a0c3f4ed5922--- /dev/null+++ b/products/ai_observability/frontend/ConversationDisplay/RedactedMediaPlaceholder.stories.tsx@@ -0,0 +1,23 @@+import type { Meta, StoryObj } from '@storybook/react'++import { RedactedMediaPlaceholder, RedactedMediaPlaceholderProps } from './RedactedMediaPlaceholder'++const meta: Meta = {+ title: 'Scenes-App/AI observability/Redacted media placeholder',+}+export default meta++export const Image: StoryObj<RedactedMediaPlaceholderProps> = {+ render: (args) => <RedactedMediaPlaceholder {...args} />,+ args: { kind: 'image' },+}++export const File: StoryObj<RedactedMediaPlaceholderProps> = {+ render: (args) => <RedactedMediaPlaceholder {...args} />,+ args: { kind: 'file' },+}++export const Audio: StoryObj<RedactedMediaPlaceholderProps> = {+ render: (args) => <RedactedMediaPlaceholder {...args} />,+ args: { kind: 'audio' },+}diff --git a/products/ai_observability/frontend/ConversationDisplay/RedactedMediaPlaceholder.tsx b/products/ai_observability/frontend/ConversationDisplay/RedactedMediaPlaceholder.tsxnew file mode 100644index 000000000000..4418134fd784--- /dev/null+++ b/products/ai_observability/frontend/ConversationDisplay/RedactedMediaPlaceholder.tsx@@ -0,0 +1,38 @@+import { IconEyeHidden } from 'lib/lemon-ui/icons'+import { Link } from 'lib/lemon-ui/Link'++import type { RedactedMediaKind } from '../mediaSource'++const LARGE_EVENTS_DOCS_URL = 'https://posthog.com/docs/ai-observability/large-events'++const KIND_LABELS: Record<RedactedMediaKind, string> = {+ image: 'Image',+ file: 'File',+ audio: 'Audio',+}++export interface RedactedMediaPlaceholderProps {+ kind: RedactedMediaKind+ filename?: string+}++export function RedactedMediaPlaceholder({ kind, filename }: RedactedMediaPlaceholderProps): JSX.Element {+ return (+ <div+ className="flex items-start gap-2 p-2 text-xs text-muted bg-bg-light rounded border"+ data-attr="ai-message-redacted-media"+ >+ <IconEyeHidden className="shrink-0 mt-0.5 text-base" />+ <div>+ <div className="font-semibold">{KIND_LABELS[kind]} not captured.</div>+ <div>+ PostHog redacts base64 media by default. Capturing it in full is in beta.{' '}+ <Link to={LARGE_EVENTS_DOCS_URL} target="_blank">+ Learn more about large events+ </Link>+ </div>+ {filename && <div className="mt-1 font-mono">{filename}</div>}+ </div>+ </div>+ )+}diff --git a/products/ai_observability/frontend/mediaSource.test.ts b/products/ai_observability/frontend/mediaSource.test.tsnew file mode 100644index 000000000000..249f7e25b98f--- /dev/null+++ b/products/ai_observability/frontend/mediaSource.test.ts@@ -0,0 +1,105 @@+import { isRedactedMediaSentinel, isRenderableMediaSource, redactedMediaKind } from './mediaSource'++const HASH = 'a'.repeat(64)+const POINTER = `phaiblob://v1/sha256/${HASH}?mime=image%2Fpng&size=131072`+const DATA_URI = 'data:image/png;base64,iVBORw0KGgo='+const REMOTE_URL = 'https://example.com/a.png'+const BASE64 = 'iVBORw0KGgo='++describe('mediaSource', () => {+ describe('redactedMediaKind', () => {+ it.each([+ ['python image sentinel', { type: 'image_url', image_url: { url: '[base64 image redacted]' } }, 'image'],+ ['node image sentinel', { type: 'image_url', image_url: { url: '[base64 image/png redacted]' } }, 'image'],+ [+ 'file sentinel',+ { type: 'file', file: { file_data: '[base64 file redacted]', filename: 'doc.pdf' } },+ 'file',+ ],+ [+ 'anthropic image sentinel',+ { type: 'image', source: { type: 'base64', media_type: 'image/png', data: '[base64 image redacted]' } },+ 'image',+ ],+ [+ 'gemini image sentinel',+ { type: 'image', inline_data: { mime_type: 'image/png', data: '[base64 image redacted]' } },+ 'image',+ ],+ ['audio sentinel', { type: 'audio', mime_type: 'audio/wav', data: '[base64 audio redacted]' }, 'audio'],+ ['vercel image sentinel', { type: 'image', image: '[base64 image redacted]' }, 'image'],+ ['input_image sentinel', { type: 'input_image', image_url: '[base64 image redacted]' }, 'image'],+ [+ 'sentinel wrapped in a data uri',+ { type: 'image_url', image_url: { url: 'data:image/png;base64,[base64 image redacted]' } },+ 'image',+ ],+ ['url that is not a source at all', { type: 'image_url', image_url: { url: 'nonsense' } }, 'image'],+ ])('flags %s as redacted', (_name, item, expected) => {+ expect(redactedMediaKind(item)).toBe(expected)+ })++ it.each([+ ['inline data uri', { type: 'image_url', image_url: { url: DATA_URI } }],+ ['offloaded blob pointer', { type: 'image_url', image_url: { url: POINTER } }],+ ['plain remote https url', { type: 'image_url', image_url: { url: REMOTE_URL } }],+ ['vercel image data uri', { type: 'image', image: DATA_URI }],+ [+ 'anthropic raw base64',+ { type: 'image', source: { type: 'base64', media_type: 'image/png', data: BASE64 } },+ ],+ ['gemini raw base64', { type: 'image', inline_data: { mime_type: 'image/png', data: BASE64 } }],+ [+ 'anthropic offloaded pointer',+ { type: 'image', source: { type: 'base64', media_type: 'image/png', data: POINTER } },+ ],+ ['gemini offloaded pointer', { type: 'image', inline_data: { mime_type: 'image/png', data: POINTER } }],+ ['audio raw base64', { type: 'audio', mime_type: 'audio/wav', data: BASE64 }],+ ['file as data uri', { type: 'file', file: { file_data: DATA_URI, filename: 'doc.pdf' } }],+ ['file as raw base64', { type: 'file', file: { file_data: BASE64, filename: 'doc.pdf' } }],+ ['text part', { type: 'text', text: 'hello' }],+ ['unrelated part', { type: 'function', function: { name: 'get_weather' } }],+ ])('leaves %s renderable', (_name, item) => {+ expect(redactedMediaKind(item)).toBeNull()+ })+ })++ describe('isRedactedMediaSentinel', () => {+ it.each([+ '[base64 image redacted]',+ '[base64 image/png redacted]',+ '[base64 file redacted]',+ '[base64 audio/mpeg redacted]',+ '[base64 redacted]',+ 'data:image/png;base64,[base64 image redacted]',+ 'data:;base64,[base64 image redacted]',+ 'data:image/png;charset=utf-8;base64,[base64 image redacted]',+ 'DATA:IMAGE/PNG;BASE64,[base64 image redacted]',+ ])('matches %s', (value) => {+ expect(isRedactedMediaSentinel(value)).toBe(true)+ })++ it.each([DATA_URI, POINTER, REMOTE_URL, BASE64, 'nonsense'])('does not match %s', (value) => {+ expect(isRedactedMediaSentinel(value)).toBe(false)+ })+ })++ describe('isRenderableMediaSource', () => {+ it.each([DATA_URI, POINTER, REMOTE_URL, 'http://example.com/a.png'])('accepts %s', (value) => {+ expect(isRenderableMediaSource(value)).toBe(true)+ })++ it.each([+ '[base64 image redacted]',+ 'data:image/png;base64,[base64 image redacted]',+ 'data:;base64,[base64 image redacted]',+ 'data:image/png;charset=utf-8;base64,[base64 image redacted]',+ 'DATA:IMAGE/PNG;BASE64,[base64 image redacted]',+ BASE64,+ 'nonsense',+ '',+ ])('rejects %s', (value) => {+ expect(isRenderableMediaSource(value)).toBe(false)+ })+ })+})diff --git a/products/ai_observability/frontend/mediaSource.ts b/products/ai_observability/frontend/mediaSource.tsnew file mode 100644index 000000000000..4cf10549759b--- /dev/null+++ b/products/ai_observability/frontend/mediaSource.ts@@ -0,0 +1,83 @@+import { parseAiBlobPointer } from './aiBlob'+import {+ getGeminiInlineData,+ isAnthropicDocumentMessage,+ isAnthropicImageMessage,+ isGeminiAudioMessage,+ isGeminiDocumentMessage,+ isGeminiImageMessage,+ isOpenAIAudioMessage,+ isOpenAIFileMessage,+ isOpenAIImageURLMessage,+} from './utils'++export type RedactedMediaKind = 'image' | 'file' | 'audio'++// Without enable_full_ai_capture the SDKs drop the payload and leave a marker in its place. The+// wording varies per SDK and per media type, so match the shape rather than a fixed set of strings.+const SENTINEL_RE = /^\s*\[base64\b[^\]]*\bredacted\]\s*$/i+// Deliberately loose: recipes build this prefix by template, so the mime can be absent or carry+// extra parameters. A stricter pattern would let a wrapped sentinel through as a renderable source.+const BASE64_DATA_URI_PREFIX = /^data:[^,]*;base64,/i++export function isRedactedMediaSentinel(value: string): boolean {+ return SENTINEL_RE.test(value.replace(BASE64_DATA_URI_PREFIX, ''))+}++export function isRenderableMediaSource(value: string): boolean {+ if (isRedactedMediaSentinel(value)) {+ return false+ }+ return /^data:/i.test(value) || /^https?:\/\//i.test(value) || parseAiBlobPointer(value) !== null+}++function hasRedactedGeminiInlineData(item: unknown): boolean {+ const inlineData = getGeminiInlineData(item)+ return inlineData !== null && isRedactedMediaSentinel(inlineData.data)+}++/**+ * Classifies a content item that cannot be rendered as media, so the caller can show a placeholder+ * instead of handing the value to the browser as a src. Branches are ordered to match the render+ * ladder in ConversationMessagesDisplay, so the shape judged here is the shape that would render.+ */+export function redactedMediaKind(item: unknown): RedactedMediaKind | null {+ if (!item || typeof item !== 'object' || !('type' in item)) {+ return null+ }++ // A url field has to carry a real source. Anything else, sentinel or not, resolves against the+ // page and 404s, so the whitelist is the gate.+ if (item.type === 'image' && 'image' in item && typeof item.image === 'string') {+ return isRenderableMediaSource(item.image) ? null : 'image'+ }+ if (item.type === 'input_image' && 'image_url' in item && typeof item.image_url === 'string') {+ return isRenderableMediaSource(item.image_url) ? null : 'image'+ }+ if (isOpenAIImageURLMessage(item)) {+ return isRenderableMediaSource(item.image_url.url) ? null : 'image'+ }++ // Payload fields legitimately hold bare base64, which no whitelist can accept, so only the+ // sentinel disqualifies them.+ if (isAnthropicImageMessage(item)) {+ return isRedactedMediaSentinel(item.source.data) ? 'image' : null+ }+ if (isGeminiImageMessage(item)) {+ return hasRedactedGeminiInlineData(item) ? 'image' : null+ }+ if (isOpenAIFileMessage(item)) {+ return isRedactedMediaSentinel(item.file.file_data) ? 'file' : null+ }+ if (isAnthropicDocumentMessage(item)) {+ return isRedactedMediaSentinel(item.source.data) ? 'file' : null+ }+ if (isGeminiDocumentMessage(item)) {+ return hasRedactedGeminiInlineData(item) ? 'file' : null+ }+ if (isOpenAIAudioMessage(item) || isGeminiAudioMessage(item)) {+ return isRedactedMediaSentinel(item.data) ? 'audio' : null+ }++ return null+}