Fix API key priority and compaction bugs

- getEnvApiKey: ANTHROPIC_OAUTH_TOKEN now takes precedence over ANTHROPIC_API_KEY
- findCutPoint: Stop scan-backwards loop at session header (was decrementing past it causing null preparation)
- generateSummary/generateTurnPrefixSummary: Throw on stopReason=error instead of returning empty string
- Test files: Fix API key priority order, use keepRecentTokens=1 for small test conversations
This commit is contained in:
Mario Zechner 2025-12-26 00:05:02 +01:00
parent c58d5f20a4
commit 251fea752c
7 changed files with 98 additions and 110 deletions

View file

@ -23,8 +23,15 @@ export default function (pi: HookAPI) {
ctx.ui.notify("Custom compaction hook triggered", "info");
const { messagesToSummarize, messagesToKeep, previousSummary, tokensBefore, resolveApiKey, entries, signal } =
event;
const {
messagesToSummarize,
messagesToKeep,
previousSummary,
tokensBefore,
resolveApiKey,
entries: _,
signal,
} = event;
// Use Gemini Flash for summarization (cheaper/faster than most conversation models)
const model = getModel("google", "gemini-2.5-flash");