Introduce context compaction: optimize conversation context persistence, reduce redundant tokens, and enhance summary handling.
CI / check (22) (push) Failing after 4m51s
CI / check (24) (push) Failing after 4m51s

This commit is contained in:
2026-10-16 14:09:23 +02:00
parent 99aff83a23
commit be4cce67f7
6 changed files with 90 additions and 23 deletions
+5 -5
View File
@@ -754,10 +754,10 @@ test("chat context summary rolls up older messages into future payloads", async
let latestPayload = [];
let summaryModel = null;
const modelService = {
async generateReply(model, messagesPayload) {
if (messagesPayload.some((message) => message.content.includes("Merge the previous summary"))) {
async generateReply(model, messagesPayload, options = {}) {
if (options.format && messagesPayload.some((message) => message.content.includes("Newly expired conversation records"))) {
summaryModel = model;
return "Summary: user greeted the assistant and asked for continuity.";
return JSON.stringify({summary: "user greeted the assistant and asked for continuity.", current_goals: [], important_facts: ["user greeted the assistant"], decisions: [], constraints: [], technical_state: [], open_tasks: [], problems_and_solutions: [], user_preferences: [], important_exact_values: []});
}
latestPayload = messagesPayload;
replyCount += 1;
@@ -781,7 +781,7 @@ test("chat context summary rolls up older messages into future payloads", async
};
const server = await startTestServer({
modelService,
config: {chatHistoryLimit: 2, chatSummaryUpdateEveryMessages: 2}
config: {chatHistoryLimit: 2, chatSummaryUpdateEveryMessages: 2, contextModel: "configured:context", contextCompactionTriggerTokens: 1, contextCompactionRecentTokens: 1, contextCompactionMinMessages: 2}
});
const jar = new CookieJar();
@@ -812,7 +812,7 @@ test("chat context summary rolls up older messages into future payloads", async
assert.ok(latestPayload.some((message) => message.role === "system" && message.content.includes("CONVERSATION SUMMARY")));
assert.ok(latestPayload.some((message) => message.content.includes("user greeted the assistant")));
assert.equal(summaryModel, "nomic-embed-text:latest");
assert.equal(summaryModel, "configured:context");
await server.close();
});