Skip to content

Commit 21f0661

Browse files
Add raw message content to proxy mismatch diagnostics
Log the pre-normalization raw message alongside the normalized one to identify what content is being dropped during normalization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 49f43fb commit 21f0661

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/harness/replayingCapiProxy.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,14 @@ async function exitWithNoMatchingRequestError(
397397
);
398398
const requestMessages = normalized.conversations[0]?.messages ?? [];
399399

400-
diagnostics += `Request has ${requestMessages.length} messages.\n`;
400+
// Also parse raw messages to see what normalization drops
401+
let rawMessages: unknown[] = [];
402+
try {
403+
const parsed = JSON.parse(options.body ?? "{}") as { messages?: unknown[] };
404+
rawMessages = parsed.messages ?? [];
405+
} catch { /* ignore */ }
406+
407+
diagnostics += `Request has ${requestMessages.length} normalized messages (${rawMessages.length} raw).\n`;
401408

402409
if (storedData) {
403410
for (let c = 0; c < storedData.conversations.length; c++) {
@@ -413,7 +420,8 @@ async function exitWithNoMatchingRequestError(
413420
const savedMsg = JSON.stringify(saved[i]);
414421
if (reqMsg !== savedMsg) {
415422
mismatchAt = i;
416-
diagnostics += `Mismatch at message ${i}:\n request: ${reqMsg.slice(0, 200)}\n saved: ${savedMsg.slice(0, 200)}\n`;
423+
const rawMsg = i < rawMessages.length ? JSON.stringify(rawMessages[i]).slice(0, 300) : "(no raw)";
424+
diagnostics += `Mismatch at message ${i}:\n normalized: ${reqMsg.slice(0, 200)}\n saved: ${savedMsg.slice(0, 200)}\n raw: ${rawMsg}\n`;
417425
break;
418426
}
419427
}

0 commit comments

Comments
 (0)