diff --git a/bun.lock b/bun.lock index 33264cb29..e6d420db5 100644 --- a/bun.lock +++ b/bun.lock @@ -381,7 +381,7 @@ }, "packages/tfcode": { "name": "tfcode", - "version": "1.0.7", + "version": "1.0.8", "bin": { "tfcode": "./bin/tfcode", }, diff --git a/packages/tfcode/package.json b/packages/tfcode/package.json index d51733857..ac592e701 100644 --- a/packages/tfcode/package.json +++ b/packages/tfcode/package.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/package.json", - "version": "1.0.7", + "version": "1.0.8", "name": "tfcode", "type": "module", "license": "MIT", diff --git a/packages/tfcode/src/session/compaction.ts b/packages/tfcode/src/session/compaction.ts index 072ea1d57..764d2fbab 100644 --- a/packages/tfcode/src/session/compaction.ts +++ b/packages/tfcode/src/session/compaction.ts @@ -29,6 +29,7 @@ export namespace SessionCompaction { } const COMPACTION_BUFFER = 20_000 + const COMPACTION_BUFFER_TOOTHFAIRYAI = 100_000 export async function isOverflow(input: { tokens: MessageV2.Assistant["tokens"]; model: Provider.Model }) { const config = await Config.get() @@ -40,8 +41,11 @@ export namespace SessionCompaction { input.tokens.total || input.tokens.input + input.tokens.output + input.tokens.cache.read + input.tokens.cache.write - const reserved = - config.compaction?.reserved ?? Math.min(COMPACTION_BUFFER, ProviderTransform.maxOutputTokens(input.model)) + const defaultBuffer = + input.model.providerID === "toothfairyai" + ? COMPACTION_BUFFER_TOOTHFAIRYAI + : Math.min(COMPACTION_BUFFER, ProviderTransform.maxOutputTokens(input.model)) + const reserved = config.compaction?.reserved ?? defaultBuffer const usable = input.model.limit.input ? input.model.limit.input - reserved : context - ProviderTransform.maxOutputTokens(input.model)