fix: remove redundant length guard and fix compact type indentation
This commit is contained in:
parent
d21d4e035a
commit
60163ccf50
|
|
@ -879,7 +879,7 @@ export class AgentRunner {
|
|||
strategy: Extract<ContextStrategy, { type: 'compact' }>,
|
||||
): LLMMessage[] {
|
||||
const estimated = estimateTokens(messages)
|
||||
if (estimated <= strategy.maxTokens || messages.length < 4) {
|
||||
if (estimated <= strategy.maxTokens) {
|
||||
return messages
|
||||
}
|
||||
|
||||
|
|
|
|||
24
src/types.ts
24
src/types.ts
|
|
@ -70,18 +70,18 @@ export type ContextStrategy =
|
|||
| { type: 'sliding-window'; maxTurns: number }
|
||||
| { type: 'summarize'; maxTokens: number; summaryModel?: string }
|
||||
| {
|
||||
type: 'compact'
|
||||
/** Estimated token threshold that triggers compaction. Compaction is skipped when below this. */
|
||||
maxTokens: number
|
||||
/** Number of recent turn pairs (assistant+user) to keep intact. Default: 4. */
|
||||
preserveRecentTurns?: number
|
||||
/** Minimum chars in a tool_result content to qualify for compaction. Default: 200. */
|
||||
minToolResultChars?: number
|
||||
/** Minimum chars in an assistant text block to qualify for truncation. Default: 2000. */
|
||||
minTextBlockChars?: number
|
||||
/** Maximum chars to keep from a truncated text block (head excerpt). Default: 200. */
|
||||
textBlockExcerptChars?: number
|
||||
}
|
||||
type: 'compact'
|
||||
/** Estimated token threshold that triggers compaction. Compaction is skipped when below this. */
|
||||
maxTokens: number
|
||||
/** Number of recent turn pairs (assistant+user) to keep intact. Default: 4. */
|
||||
preserveRecentTurns?: number
|
||||
/** Minimum chars in a tool_result content to qualify for compaction. Default: 200. */
|
||||
minToolResultChars?: number
|
||||
/** Minimum chars in an assistant text block to qualify for truncation. Default: 2000. */
|
||||
minTextBlockChars?: number
|
||||
/** Maximum chars to keep from a truncated text block (head excerpt). Default: 200. */
|
||||
textBlockExcerptChars?: number
|
||||
}
|
||||
| {
|
||||
type: 'custom'
|
||||
compress: (
|
||||
|
|
|
|||
Loading…
Reference in New Issue