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