refactor(agent): return results from compaction helpers

This commit is contained in:
Mario Zechner
2026-05-14 21:56:45 +02:00
parent b7ea82105a
commit a31ce0f47f
5 changed files with 452 additions and 63 deletions
+13 -11
View File
@@ -634,17 +634,19 @@ export class AgentHarness<
throw new Error("Compaction cancelled");
}
const provided = hookResult?.compaction;
const result =
provided ??
(await compact(
preparation,
model,
auth.apiKey,
auth.headers,
customInstructions,
undefined,
this.thinkingLevel,
));
const compactResult = provided
? { ok: true as const, value: provided }
: await compact(
preparation,
model,
auth.apiKey,
auth.headers,
customInstructions,
undefined,
this.thinkingLevel,
);
if (!compactResult.ok) throw compactResult.error;
const result = compactResult.value;
const entryId = await this.session.appendCompaction(
result.summary,
result.firstKeptEntryId,