feat(video): redact transcript in the in-memory pending-request snapshot (#12430 item 6) (#12596)

* feat(video): redact transcript fields in the in-memory pending-request snapshot (#12430 item 6)

trackPendingRequest (open-sse/handlers/chatCore.ts) stored the raw client
body (with video transcript/audioTranscript cues) under `clientRequest`,
live-exposed via /api/usage/call-logs (pendingDetails), /api/logs/[id] and
/api/conversations while a request is in-flight. P2a redacted the persisted
detailed-log snapshot but not this in-memory copy.

Add redactPendingBody() to videoBridgeSnapshotRedaction.ts (sibling to
logClientRawRequestRedacted from P2a): when videoBridgeObserved, returns the
redacted clone from redactVideoTranscriptFieldsForLog; otherwise returns the
exact same reference. Wire it into the trackPendingRequest call site
(chatCore.ts:934), keeping the file within its frozen 5976-line budget
(5971 -> 5974).

* feat(video): substring-redact transcript in derived-prompt dispatch logs (#12430 item 4)

Extend applyVideoBridgeLogRedaction with a string-content branch:
pipeline-strategy stages, smart-auto-pipeline, and context-handoff
summaries embed the transcript as a substring of a rendered prompt
string rather than an exact array part, so the existing exact
part-array match silently skipped them. Adds a mutually-exclusive
string branch (Array.isArray vs typeof === "string") that does a
replaceAll of the trusted fullText literal against a lazily cloned
message, reusing the existing rootClone/clonedContainers/clonedMessages
clone-on-write pattern so siblings keep original references and the
input is never mutated.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-09-03 10:49:01 -03:00
committed by GitHub
parent 2c4ad3e557
commit 9af3ec5112
5 changed files with 312 additions and 3 deletions

View File

@@ -133,3 +133,17 @@ export function logClientRawRequestRedacted(
clientRawRequest.headers
);
}
/**
* Call-site wrapper for the `clientRequest` field stored by `trackPendingRequest`
* (open-sse/handlers/chatCore.ts): the sibling in-memory leak to
* `logClientRawRequestRedacted` above — same raw body, but live-exposed via
* /api/usage/call-logs (pendingDetails), /api/logs/[id] and /api/conversations
* while the request is in-flight, not just in the persisted detailed-log
* snapshot. Identical observed/non-observed branching: a non-observed request
* keeps the exact same reference (no clone); an observed one gets the redacted
* clone.
*/
export function redactPendingBody(clientRequest: unknown, videoBridgeObserved: boolean): unknown {
return videoBridgeObserved ? redactVideoTranscriptFieldsForLog(clientRequest) : clientRequest;
}