fix(hooks): pass sessionFile and sessionKey in after_compaction hook (#40781)

Merged via squash.

Prepared head SHA: 11e85f8651
Co-authored-by: jarimustonen <1272053+jarimustonen@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
Jari Mustonen
2026-03-17 17:30:37 +02:00
committed by GitHub
parent f036ed27f4
commit 4f6955fb11
5 changed files with 22 additions and 4 deletions

View File

@@ -529,6 +529,7 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
messageCount: 1,
tokenCount: 10,
compactedCount: 1,
sessionFile: "/tmp/session.jsonl",
},
expect.objectContaining({ sessionKey: "agent:main:session-1", messageProvider: "telegram" }),
);

View File

@@ -1039,6 +1039,7 @@ export async function compactEmbeddedPiSessionDirect(
messageCount: messageCountAfter,
tokenCount: tokensAfter,
compactedCount,
sessionFile: params.sessionFile,
},
{
sessionId: params.sessionId,

View File

@@ -80,8 +80,9 @@ export function handleAutoCompactionEnd(
{
messageCount: ctx.params.session.messages?.length ?? 0,
compactedCount: ctx.getCompactionCount(),
sessionFile: ctx.params.session.sessionFile,
},
{},
{ sessionKey: ctx.params.sessionKey },
)
.catch((err) => {
ctx.log.warn(`after_compaction hook failed: ${String(err)}`);