UNPKG

@openai/agents-core

Version:

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.

32 lines • 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.applySessionHistoryMutations = applySessionHistoryMutations; /** * Applies persisted-history mutations and returns a new canonical item list. */ function applySessionHistoryMutations(items, mutations) { let nextItems = items.map((item) => structuredClone(item)); for (const mutation of mutations) { if (mutation.type === 'replace_function_call') { nextItems = applyReplaceFunctionCallMutation(nextItems, mutation); } } return nextItems; } function applyReplaceFunctionCallMutation(items, mutation) { const replacement = structuredClone(mutation.replacement); const nextItems = []; let keptReplacement = false; for (const item of items) { if (item.type === 'function_call' && item.callId === mutation.callId) { if (!keptReplacement) { nextItems.push(replacement); keptReplacement = true; } continue; } nextItems.push(item); } return nextItems; } //# sourceMappingURL=historyMutations.js.map