mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 11:03:44 +00:00
Use token-based maxTokens instead of fraction-based reserveFraction
- BranchSummarySettings.maxTokens (default 100000) instead of reserveFraction - More intuitive and consistent with CompactionSettings.keepRecentTokens
This commit is contained in:
parent
839a46e6fe
commit
f5f39f08f1
3 changed files with 8 additions and 12 deletions
|
|
@ -53,8 +53,8 @@ export interface GenerateBranchSummaryOptions {
|
|||
signal: AbortSignal;
|
||||
/** Optional custom instructions for summarization */
|
||||
customInstructions?: string;
|
||||
/** Reserve this fraction of context window for summary (default 0.2) */
|
||||
reserveFraction?: number;
|
||||
/** Maximum tokens to include in summary context (default 100000) */
|
||||
maxTokens?: number;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
@ -321,13 +321,9 @@ export async function generateBranchSummary(
|
|||
entries: SessionEntry[],
|
||||
options: GenerateBranchSummaryOptions,
|
||||
): Promise<BranchSummaryResult> {
|
||||
const { model, apiKey, signal, customInstructions, reserveFraction = 0.2 } = options;
|
||||
const { model, apiKey, signal, customInstructions, maxTokens = 100000 } = options;
|
||||
|
||||
// Calculate token budget (leave room for summary generation)
|
||||
const contextWindow = model.contextWindow || 128000;
|
||||
const tokenBudget = Math.floor(contextWindow * (1 - reserveFraction));
|
||||
|
||||
const { messages, fileOps } = prepareBranchEntries(entries, tokenBudget);
|
||||
const { messages, fileOps } = prepareBranchEntries(entries, maxTokens);
|
||||
|
||||
if (messages.length === 0) {
|
||||
return { summary: "No content to summarize" };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue