fix(agents): guard replay convert hook

This commit is contained in:
Ayaan Zaidi
2026-04-22 11:14:17 +05:30
parent 344a88f931
commit 54311a7a34

View File

@@ -1144,9 +1144,11 @@ export async function runEmbeddedAttempt(
throw new Error("Embedded agent session missing");
}
const activeSession = session;
const baseConvertToLlm = activeSession.agent.convertToLlm.bind(activeSession.agent);
activeSession.agent.convertToLlm = async (messages) =>
await baseConvertToLlm(normalizeAssistantReplayContent(messages));
if (typeof activeSession.agent.convertToLlm === "function") {
const baseConvertToLlm = activeSession.agent.convertToLlm.bind(activeSession.agent);
activeSession.agent.convertToLlm = async (messages) =>
await baseConvertToLlm(normalizeAssistantReplayContent(messages));
}
let prePromptMessageCount = activeSession.messages.length;
abortSessionForYield = () => {
yieldAbortSettled = Promise.resolve(activeSession.abort());