Skip to content

Commit 566b0e5

Browse files
authored
fix(ai): retain compaction-only replay checkpoints (#127106)
* test(gateway): publish runtime in agent E2Es * test(gateway): leave replay fix to owner PR * fix(ai): retain compaction-only replay checkpoints * fix(ai): preserve empty compaction replay checkpoints
1 parent 7085604 commit 566b0e5

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/ai/src/transports/provider-compaction-replay.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ describe("compaction replay owner rewrites", () => {
110110
expect(JSON.stringify(input)).toContain("full history prefix");
111111
});
112112

113+
it("keeps a compaction-only checkpoint through an unchanged empty-content projection", () => {
114+
const owner = createAssistant([], 0);
115+
const projected = replaceCompactionReplayOwnerContent(owner, []);
116+
117+
expect(projected.providerReplay).toBe(owner.providerReplay);
118+
});
119+
113120
it("keeps retained-user checkpoints independent of owner content indexes", () => {
114121
const retained = createAssistant([{ type: "text", text: "removed owner output" }], 0);
115122
const providerReplay = retained.providerReplay;

‎packages/ai/src/transports/provider-compaction-replay.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ export function replaceCompactionReplayOwnerContent(
4545
return next;
4646
}
4747
const replayIndex = replay.replayIndex ?? 0;
48-
if (content.length === 0 || replayIndex > message.content.length) {
48+
if (
49+
(content.length === 0 && message.content.length > 0) ||
50+
replayIndex > message.content.length
51+
) {
4952
return stripCompactionReplayCheckpoint(next);
5053
}
5154
let sourceIndex = 0;

‎test/gateway-openai-compaction-replay.e2e.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe("Gateway OpenAI Responses compaction replay", () => {
5050
env: {
5151
OPENCLAW_DEBUG_MODEL_TRANSPORT: "1",
5252
OPENCLAW_SKIP_PROVIDERS: undefined,
53+
OPENCLAW_TEST_MINIMAL_GATEWAY: undefined,
5354
},
5455
});
5556
instances.push(instance);

0 commit comments

Comments
 (0)