MCPcopy Create free account
hub / github.com/Noumena-Network/code / getCompactionReminderAttachment

Function getCompactionReminderAttachment

src/utils/attachments.ts:3938–3962  ·  view source on GitHub ↗
(
  messages: Message[],
  model: string,
)

Source from the content-addressed store, hash-verified

3936}
3937
3938export 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

Callers 1

getAttachmentsFunction · 0.85

Calls 6

isAutoCompactEnabledFunction · 0.85
getContextWindowForModelFunction · 0.85
getSdkBetasFunction · 0.85
tokenCountWithEstimationFunction · 0.85

Tested by

no test coverage detected