mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 09:01:20 +00:00
Pass fromHook to appendCompaction for both manual and auto compaction
This commit is contained in:
parent
f118cdc67b
commit
d4dc07ab20
2 changed files with 10 additions and 3 deletions
|
|
@ -965,7 +965,7 @@ export class AgentSession {
|
||||||
throw new Error("Compaction cancelled");
|
throw new Error("Compaction cancelled");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details);
|
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromHook);
|
||||||
const newEntries = this.sessionManager.getEntries();
|
const newEntries = this.sessionManager.getEntries();
|
||||||
const sessionContext = this.sessionManager.buildSessionContext();
|
const sessionContext = this.sessionManager.buildSessionContext();
|
||||||
this.agent.replaceMessages(sessionContext.messages);
|
this.agent.replaceMessages(sessionContext.messages);
|
||||||
|
|
@ -1139,7 +1139,7 @@ export class AgentSession {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details);
|
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromHook);
|
||||||
const newEntries = this.sessionManager.getEntries();
|
const newEntries = this.sessionManager.getEntries();
|
||||||
const sessionContext = this.sessionManager.buildSessionContext();
|
const sessionContext = this.sessionManager.buildSessionContext();
|
||||||
this.agent.replaceMessages(sessionContext.messages);
|
this.agent.replaceMessages(sessionContext.messages);
|
||||||
|
|
|
||||||
|
|
@ -641,7 +641,13 @@ export class SessionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Append a compaction summary as child of current leaf, then advance leaf. Returns entry id. */
|
/** Append a compaction summary as child of current leaf, then advance leaf. Returns entry id. */
|
||||||
appendCompaction<T = unknown>(summary: string, firstKeptEntryId: string, tokensBefore: number, details?: T): string {
|
appendCompaction<T = unknown>(
|
||||||
|
summary: string,
|
||||||
|
firstKeptEntryId: string,
|
||||||
|
tokensBefore: number,
|
||||||
|
details?: T,
|
||||||
|
fromHook?: boolean,
|
||||||
|
): string {
|
||||||
const entry: CompactionEntry<T> = {
|
const entry: CompactionEntry<T> = {
|
||||||
type: "compaction",
|
type: "compaction",
|
||||||
id: generateId(this.byId),
|
id: generateId(this.byId),
|
||||||
|
|
@ -651,6 +657,7 @@ export class SessionManager {
|
||||||
firstKeptEntryId,
|
firstKeptEntryId,
|
||||||
tokensBefore,
|
tokensBefore,
|
||||||
details,
|
details,
|
||||||
|
fromHook,
|
||||||
};
|
};
|
||||||
this._appendEntry(entry);
|
this._appendEntry(entry);
|
||||||
return entry.id;
|
return entry.id;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue