@howaboua/pi-codex-conversion 1.5.7 → 1.5.8-dev.33.e99b6a4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.8
|
|
4
|
+
|
|
5
|
+
- Fixed native Responses compaction replay after compaction display messages so requests replace Pi placeholder compaction context with the native compacted window instead of failing parity checks.
|
|
6
|
+
|
|
3
7
|
## 1.5.7
|
|
4
8
|
|
|
5
9
|
- Fixed OpenAI Codex custom-provider requests so synthetic `web.run` and `image_generation` adapter tools are rewritten to native Responses tool payloads before sending.
|
package/package.json
CHANGED
|
@@ -269,6 +269,13 @@ function toReplayAgentMessage(entry: SessionEntry): AgentMessage | undefined {
|
|
|
269
269
|
return undefined;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
function toPiReplayAgentMessage(entry: SessionEntry): AgentMessage | undefined {
|
|
273
|
+
if (entry.type === "message") return toSessionMessage(entry);
|
|
274
|
+
if (entry.type === "custom_message") return toCustomMessage(entry);
|
|
275
|
+
if (entry.type === "branch_summary") return toBranchSummaryMessage(entry);
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
|
|
272
279
|
function isPromptEnvelopeItem(item: unknown): item is ResponsesInputMessageItem {
|
|
273
280
|
return isResponsesInputMessageItem(item) && isPreambleRole(item.role);
|
|
274
281
|
}
|
|
@@ -322,6 +329,15 @@ export function collectReplayMessages(entries: readonly SessionEntry[]): AgentMe
|
|
|
322
329
|
return messages;
|
|
323
330
|
}
|
|
324
331
|
|
|
332
|
+
function collectPiReplayMessages(entries: readonly SessionEntry[]): AgentMessage[] {
|
|
333
|
+
const messages: AgentMessage[] = [];
|
|
334
|
+
for (const entry of entries) {
|
|
335
|
+
const message = toPiReplayAgentMessage(entry);
|
|
336
|
+
if (message) messages.push(message);
|
|
337
|
+
}
|
|
338
|
+
return messages;
|
|
339
|
+
}
|
|
340
|
+
|
|
325
341
|
function createCompactionSummaryAgentMessage(entry: NativeCompactionEntry): AgentMessage {
|
|
326
342
|
return {
|
|
327
343
|
role: "compactionSummary",
|
|
@@ -437,8 +453,9 @@ function buildNativeReplaySegmentsInternal<TApi extends Api>(args: {
|
|
|
437
453
|
|
|
438
454
|
const preCompactionEntries = args.branchEntries.slice(firstKeptEntryIndex, boundaryIndex);
|
|
439
455
|
const postCompactionEntries = args.branchEntries.slice(boundaryIndex + 1);
|
|
440
|
-
const preCompactionKeptMessages =
|
|
441
|
-
const postCompactionTailMessages =
|
|
456
|
+
const preCompactionKeptMessages = collectPiReplayMessages(preCompactionEntries);
|
|
457
|
+
const postCompactionTailMessages = collectPiReplayMessages(postCompactionEntries);
|
|
458
|
+
const contextPostCompactionTailMessages = collectReplayMessages(postCompactionEntries);
|
|
442
459
|
const compactionSummaryMessage = createCompactionSummaryAgentMessage(args.compactionEntry);
|
|
443
460
|
const serializedPiHistoryInput = serializeMessagesToResponsesInput(args.model, [
|
|
444
461
|
compactionSummaryMessage,
|
|
@@ -480,6 +497,7 @@ function buildNativeReplaySegmentsInternal<TApi extends Api>(args: {
|
|
|
480
497
|
),
|
|
481
498
|
);
|
|
482
499
|
const actualPostCompactionTail = cloneResponsesInputSlice(args.payload.input.slice(tailStartIndex, tailEndIndex));
|
|
500
|
+
const contextPostCompactionTail = serializeMessagesToResponsesInput(args.model, contextPostCompactionTailMessages);
|
|
483
501
|
if (!actualCompactionSummary || !actualPreCompactionKeptWindow || !actualPostCompactionTail) {
|
|
484
502
|
return {
|
|
485
503
|
ok: false,
|
|
@@ -494,8 +512,8 @@ function buildNativeReplaySegmentsInternal<TApi extends Api>(args: {
|
|
|
494
512
|
);
|
|
495
513
|
const postCompactionTail = createReplaySlice(
|
|
496
514
|
postCompactionEntries,
|
|
497
|
-
|
|
498
|
-
|
|
515
|
+
contextPostCompactionTailMessages,
|
|
516
|
+
contextPostCompactionTail,
|
|
499
517
|
);
|
|
500
518
|
|
|
501
519
|
return {
|
|
@@ -514,7 +532,7 @@ function buildNativeReplaySegmentsInternal<TApi extends Api>(args: {
|
|
|
514
532
|
replayInput: [
|
|
515
533
|
...freshPreamble.leadingInput,
|
|
516
534
|
...compactedWindow,
|
|
517
|
-
...
|
|
535
|
+
...contextPostCompactionTail,
|
|
518
536
|
...freshPreamble.trailingInput,
|
|
519
537
|
],
|
|
520
538
|
},
|
|
@@ -524,7 +542,7 @@ function buildNativeReplaySegmentsInternal<TApi extends Api>(args: {
|
|
|
524
542
|
input: [
|
|
525
543
|
...freshPreamble.leadingInput,
|
|
526
544
|
...compactedWindow,
|
|
527
|
-
...
|
|
545
|
+
...contextPostCompactionTail,
|
|
528
546
|
...freshPreamble.trailingInput,
|
|
529
547
|
],
|
|
530
548
|
},
|
|
Binary file
|
|
Binary file
|