( messages: Message[], model: string, )
| 3929 | } |
| 3930 | |
| 3931 | export function getCompactionReminderAttachment( |
| 3932 | messages: Message[], |
| 3933 | model: string, |
| 3934 | ): Attachment[] { |
| 3935 | if (!getFeatureValue_CACHED_MAY_BE_STALE('tengu_marble_fox', false)) { |
| 3936 | return [] |
| 3937 | } |
| 3938 | |
| 3939 | if (!isAutoCompactEnabled()) { |
| 3940 | return [] |
| 3941 | } |
| 3942 | |
| 3943 | const contextWindow = getContextWindowForModel(model, getSdkBetas()) |
| 3944 | if (contextWindow < 1_000_000) { |
| 3945 | return [] |
| 3946 | } |
| 3947 | |
| 3948 | const effectiveWindow = getEffectiveContextWindowSize(model) |
| 3949 | const usedTokens = tokenCountWithEstimation(messages) |
| 3950 | if (usedTokens < effectiveWindow * 0.25) { |
| 3951 | return [] |
| 3952 | } |
| 3953 | |
| 3954 | return [{ type: 'compaction_reminder' }] |
| 3955 | } |
| 3956 | |
| 3957 | /** |
| 3958 | * Context-efficiency nudge. Injected after every N tokens of growth without |
no test coverage detected