( messages: Message[], model: string, )
| 4011 | } |
| 4012 | |
| 4013 | export function getCompactionReminderAttachment( |
| 4014 | messages: Message[], |
| 4015 | model: string, |
| 4016 | ): Attachment[] { |
| 4017 | if (!getFeatureValue_CACHED_MAY_BE_STALE('tengu_marble_fox', false)) { |
| 4018 | return [] |
| 4019 | } |
| 4020 | |
| 4021 | if (!isAutoCompactEnabled()) { |
| 4022 | return [] |
| 4023 | } |
| 4024 | |
| 4025 | const contextWindow = getContextWindowForModel(model, getSdkBetas()) |
| 4026 | if (contextWindow < 1_000_000) { |
| 4027 | return [] |
| 4028 | } |
| 4029 | |
| 4030 | const effectiveWindow = getEffectiveContextWindowSize(model) |
| 4031 | const usedTokens = tokenCountWithEstimation(messages) |
| 4032 | if (usedTokens < effectiveWindow * 0.25) { |
| 4033 | return [] |
| 4034 | } |
| 4035 | |
| 4036 | return [{ type: 'compaction_reminder' }] |
| 4037 | } |
| 4038 | |
| 4039 | /** |
| 4040 | * Context-efficiency nudge. Injected after every N tokens of growth without |
no test coverage detected