
























@@ -6093,11 +6093,16 @@ async function mirrorTranscriptBestEffort(params: {
60936093turnId: string;
60946094}): Promise<void> {
60956095try {
6096+const messages = await resolveFinalCodexMirrorMessages({
6097+params: params.params,
6098+messagesSnapshot: params.result.messagesSnapshot,
6099+turnId: params.turnId,
6100+});
60966101const mirrorResult = await mirrorCodexAppServerTranscript({
60976102sessionFile: params.params.sessionFile,
60986103agentId: params.agentId,
60996104sessionKey: params.sessionKey,
6100-messages: params.result.messagesSnapshot,
6105+ messages,
61016106// Scope is thread-stable. Each entry in `messagesSnapshot` is tagged
61026107// with a per-turn `attachCodexMirrorIdentity` value carrying its own
61036108// turnId, so distinct turns produce distinct dedupe keys via the
@@ -6116,6 +6121,30 @@ async function mirrorTranscriptBestEffort(params: {
61166121}
61176122}
611861236124+async function resolveFinalCodexMirrorMessages(params: {
6125+params: EmbeddedRunAttemptParams;
6126+messagesSnapshot: AgentMessage[];
6127+turnId: string;
6128+}): Promise<AgentMessage[]> {
6129+if (
6130+params.params.suppressNextUserMessagePersistence ||
6131+!params.params.userTurnTranscriptRecorder
6132+) {
6133+return params.messagesSnapshot;
6134+}
6135+const resolvedPrompt = attachCodexMirrorIdentity(
6136+await buildResolvedCodexUserPromptMessage(params.params),
6137+`${params.turnId}:prompt`,
6138+);
6139+const firstUserIndex = params.messagesSnapshot.findIndex((message) => message.role === "user");
6140+if (firstUserIndex === -1) {
6141+return [resolvedPrompt, ...params.messagesSnapshot];
6142+}
6143+const messages = params.messagesSnapshot.slice();
6144+messages[firstUserIndex] = resolvedPrompt;
6145+return messages;
6146+}
6147+61196148function createCodexAppServerUserMessagePersistenceNotifier(
61206149runParams: EmbeddedRunAttemptParams,
61216150): (message: Extract<AgentMessage, { role: "user" }>) => void {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。