mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-23 19:48:12 +00:00
Compaction: avoid duplicate merge focus header
This commit is contained in:
@@ -89,6 +89,27 @@ describe("compaction identifier-preservation instructions", () => {
|
||||
expect(call[5]).toContain("Preserve all opaque identifiers exactly as written");
|
||||
}
|
||||
});
|
||||
|
||||
it("avoids duplicate additional-focus headers in split+merge path", async () => {
|
||||
await summarizeInStages({
|
||||
messages: [makeMessage(1), makeMessage(2), makeMessage(3), makeMessage(4)],
|
||||
model: testModel,
|
||||
apiKey: "test-key",
|
||||
signal: new AbortController().signal,
|
||||
reserveTokens: 4000,
|
||||
maxChunkTokens: 1000,
|
||||
contextWindow: 200_000,
|
||||
parts: 2,
|
||||
minMessagesForSplit: 4,
|
||||
customInstructions: "Prioritize customer-visible regressions.",
|
||||
});
|
||||
|
||||
const mergedCall = mockGenerateSummary.mock.calls.at(-1);
|
||||
const instructions = mergedCall?.[5] ?? "";
|
||||
expect(instructions).toContain("Merge these partial summaries into a single cohesive summary.");
|
||||
expect(instructions).toContain("Prioritize customer-visible regressions.");
|
||||
expect((instructions.match(/Additional focus:/g) ?? []).length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildCompactionSummarizationInstructions", () => {
|
||||
|
||||
@@ -335,8 +335,9 @@ export async function summarizeInStages(params: {
|
||||
timestamp: Date.now(),
|
||||
}));
|
||||
|
||||
const mergeInstructions = params.customInstructions
|
||||
? `${MERGE_SUMMARIES_INSTRUCTIONS}\n\nAdditional focus:\n${params.customInstructions}`
|
||||
const custom = params.customInstructions?.trim();
|
||||
const mergeInstructions = custom
|
||||
? `${MERGE_SUMMARIES_INSTRUCTIONS}\n\n${custom}`
|
||||
: MERGE_SUMMARIES_INSTRUCTIONS;
|
||||
|
||||
return summarizeWithFallback({
|
||||
|
||||
Reference in New Issue
Block a user