Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@types/node": "^22.0.0",
"@types/node-forge": "^1.3.14",
"acp-kernel": "0.0.34",
"acp-kernel": "0.0.36",
"fzstd": "0.1.1",
"node-forge": "^1.4.0",
"tar": "^7.5.22",
Expand Down
14 changes: 13 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import http from "node:http";
import fs from "node:fs";
import { createCore, type CompressionCore, type Config, type CoreMessage, type NudgeDecision, type Prompts, defaultPrompts, estimateTokensFast, renderNudgeText, deactivateBlock } from "acp-kernel";
import { createCore, type CompressionCore, type Config, type CoreMessage, type NudgeDecision, type Prompts, defaultPrompts, estimateTokensFast, renderNudgeText, deactivateBlock, viableRanges } from "acp-kernel";
import { resolveCompress, resolveCompressPrompts, resolveRequestConfig } from "./compress-settings.js";
import type { ProxyOptions } from "./config.js";
import { loadOptions, loadRoutes } from "./config.js";
Expand Down Expand Up @@ -870,6 +870,10 @@ function prepareAnthropic(
const tokenCount = session.stats.lastInputTokens;
const turn = core.processTurn({ messages: msgs, state: session.state, config, tokenCount, renderTags: "text-only" });
session.state = turn.state;
// Drop sub-viability fragments before any consumer sees them: a tiny
// range in the list makes batched compress attempts fail atomically
// (kernel validates the whole batch). Mirrors billion-context-pi.
if (turn.nudge) turn.nudge.compressibleRanges = viableRanges(turn.nudge.compressibleRanges);
nudge = turn.nudge;
session.stats.contextTokens = tokenCount;
if (!session.meta.title) {
Expand Down Expand Up @@ -948,6 +952,10 @@ function prepareOpenai(
const tokenCount = session.stats.lastInputTokens;
const turn = core.processTurn({ messages: msgs, state: session.state, config, tokenCount, renderTags: "text-only" });
session.state = turn.state;
// Drop sub-viability fragments before any consumer sees them: a tiny
// range in the list makes batched compress attempts fail atomically
// (kernel validates the whole batch). Mirrors billion-context-pi.
if (turn.nudge) turn.nudge.compressibleRanges = viableRanges(turn.nudge.compressibleRanges);
nudge = turn.nudge;
session.stats.contextTokens = tokenCount;
if (!session.meta.title) {
Expand Down Expand Up @@ -1044,6 +1052,10 @@ function prepareResponses(
const tokenCount = session.stats.lastInputTokens;
const turn = core.processTurn({ messages: msgs, state: session.state, config, tokenCount, renderTags: process.env.ACP_RENDER_NONE ? "none" : "text-only" });
session.state = turn.state;
// Drop sub-viability fragments before any consumer sees them: a tiny
// range in the list makes batched compress attempts fail atomically
// (kernel validates the whole batch). Mirrors billion-context-pi.
if (turn.nudge) turn.nudge.compressibleRanges = viableRanges(turn.nudge.compressibleRanges);
nudge = turn.nudge;
session.stats.contextTokens = tokenCount;
if (!session.meta.title) {
Expand Down
Loading