fix: gap calculation scoped to requested range, clearer error text

This commit is contained in:
wassname
2026-04-16 13:14:49 +08:00
parent 779e5cc240
commit b825dbcf77
2 changed files with 4 additions and 18 deletions
+2 -1
View File
@@ -173,6 +173,7 @@ export function registerCompressTool(
const sortedEntries = [...state.messageIdSnapshot.entries()] const sortedEntries = [...state.messageIdSnapshot.entries()]
.filter(([id]) => id.startsWith('m')) // only mNNN ids .filter(([id]) => id.startsWith('m')) // only mNNN ids
.filter(([, ts]) => ts >= startTimestamp && ts <= endTimestamp) // only within requested range
.sort((a, b) => a[1] - b[1]) .sort((a, b) => a[1] - b[1])
// Walk sorted messages, grouping consecutive uncovered ones into gap ranges // Walk sorted messages, grouping consecutive uncovered ones into gap ranges
@@ -213,7 +214,7 @@ export function registerCompressTool(
throw new Error( throw new Error(
`[compress] Range {startId: "${startId}", endId: "${endId}"} overlaps existing summaries: ${overlapInfo}. ` + `[compress] Range {startId: "${startId}", endId: "${endId}"} overlaps existing summaries: ${overlapInfo}. ` +
`Available ranges: ${gapInfo}`, `Available ranges within your requested range: ${gapInfo}`,
) )
} }
+2 -17
View File
@@ -1,12 +1,12 @@
{ {
"name": "@complexthings/pi-dynamic-context-pruning", "name": "@complexthings/pi-dynamic-context-pruning",
"version": "1.0.6", "version": "1.0.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@complexthings/pi-dynamic-context-pruning", "name": "@complexthings/pi-dynamic-context-pruning",
"version": "1.0.6", "version": "1.0.7",
"dependencies": { "dependencies": {
"jsonc-parser": "^3.3.1" "jsonc-parser": "^3.3.1"
}, },
@@ -913,9 +913,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -933,9 +930,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -953,9 +947,6 @@
"cpu": [ "cpu": [
"riscv64" "riscv64"
], ],
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -973,9 +964,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"glibc"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -993,9 +981,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"libc": [
"musl"
],
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [