mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 19:05:11 +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
|
|
@ -1656,7 +1656,7 @@ export class AgentSession {
|
|||
apiKey,
|
||||
signal: this._branchSummaryAbortController.signal,
|
||||
customInstructions: options.customInstructions,
|
||||
reserveFraction: branchSummarySettings.reserveFraction,
|
||||
maxTokens: branchSummarySettings.maxTokens,
|
||||
});
|
||||
this._branchSummaryAbortController = undefined;
|
||||
if (result.aborted) {
|
||||
|
|
|
|||
|
|
@ -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" };
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export interface CompactionSettings {
|
|||
}
|
||||
|
||||
export interface BranchSummarySettings {
|
||||
reserveFraction?: number; // default: 0.2 (fraction of context window reserved for summary)
|
||||
maxTokens?: number; // default: 100000 (max tokens to include in branch summary context)
|
||||
}
|
||||
|
||||
export interface RetrySettings {
|
||||
|
|
@ -260,9 +260,9 @@ export class SettingsManager {
|
|||
};
|
||||
}
|
||||
|
||||
getBranchSummarySettings(): { reserveFraction: number } {
|
||||
getBranchSummarySettings(): { maxTokens: number } {
|
||||
return {
|
||||
reserveFraction: this.settings.branchSummary?.reserveFraction ?? 0.2,
|
||||
maxTokens: this.settings.branchSummary?.maxTokens ?? 100000,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue