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