pi-roundtable-sandbox 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/pi-broker.ts +1 -0
- package/src/pi-protocol.ts +8 -3
- package/worker/pi-compaction.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.9.6
|
|
6
|
+
|
|
7
|
+
- A worker's compaction tiers measure the context left with the system prompt and tools its requests carry, as the host's do; its compaction report and the host's `conversation compacted` log add `contextAfter`.
|
|
8
|
+
|
|
5
9
|
## 0.9.5
|
|
6
10
|
|
|
7
11
|
- Release in lockstep with pi-roundtable 0.9.5; no package-specific behavior changes. 0.9.4 was tagged but never published.
|
package/README.md
CHANGED
|
@@ -331,7 +331,7 @@ Without `compaction` the worker registers no compaction handler; the tiers and P
|
|
|
331
331
|
`jevCompactor({ logger })` from `pi-roundtable/kit` is a ready compactor through Jev, the one the core's hosts use: `compaction: jevCompactor({ logger })`.
|
|
332
332
|
Compactions are written to the session file in the channel workspace, so they survive container removal and restarts.
|
|
333
333
|
|
|
334
|
-
The host logs, per channel: `conversation compacted` (`trigger`, `engine` `extension` or `pi`, `tokensBefore`, `tokensAfter`, `nextCompactionAt`), `compaction failed`, `compaction skips the extension for Pi's summary` past the ceiling, and `compaction falls back to Pi's summary` with its `fallback` reason.
|
|
334
|
+
The host logs, per channel: `conversation compacted` (`trigger`, `engine` `extension` or `pi`, `tokensBefore`, `tokensAfter`, `contextAfter`, the context the tiers measure, system prompt and tools included, and `nextCompactionAt`), `compaction failed`, `compaction skips the extension for Pi's summary` past the ceiling, and `compaction falls back to Pi's summary` with its `fallback` reason.
|
|
335
335
|
|
|
336
336
|
### Worker content and files
|
|
337
337
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-roundtable-sandbox",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Sealed guest channels and an allow-listed credential broker for pi-roundtable",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@biomejs/biome": "2.5.15",
|
|
53
53
|
"@types/bun": "1.4.2",
|
|
54
54
|
"discord.js": "14.27.0",
|
|
55
|
-
"pi-roundtable": "0.9.
|
|
55
|
+
"pi-roundtable": "0.9.6",
|
|
56
56
|
"typebox": "1.3.34",
|
|
57
57
|
"typescript": "7.0.2"
|
|
58
58
|
}
|
package/src/pi-broker.ts
CHANGED
|
@@ -1026,6 +1026,7 @@ export class PiSandboxBroker {
|
|
|
1026
1026
|
engine: report.engine,
|
|
1027
1027
|
tokensBefore: report.tokensBefore,
|
|
1028
1028
|
tokensAfter: report.tokensAfter,
|
|
1029
|
+
contextAfter: report.contextAfter,
|
|
1029
1030
|
nextCompactionAt: report.nextCompactionAt,
|
|
1030
1031
|
},
|
|
1031
1032
|
"conversation compacted",
|
package/src/pi-protocol.ts
CHANGED
|
@@ -146,6 +146,8 @@ export type PiCompactionReport =
|
|
|
146
146
|
engine?: "extension" | "pi";
|
|
147
147
|
tokensBefore?: number;
|
|
148
148
|
tokensAfter?: number;
|
|
149
|
+
/** The context the tiers measure after it, system prompt and tools included. */
|
|
150
|
+
contextAfter?: number;
|
|
149
151
|
nextCompactionAt?: number;
|
|
150
152
|
error?: string;
|
|
151
153
|
};
|
|
@@ -203,9 +205,12 @@ export function validateCompactionReport(
|
|
|
203
205
|
(value.engine === undefined ||
|
|
204
206
|
value.engine === "extension" ||
|
|
205
207
|
value.engine === "pi") &&
|
|
206
|
-
[
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
[
|
|
209
|
+
value.tokensBefore,
|
|
210
|
+
value.tokensAfter,
|
|
211
|
+
value.contextAfter,
|
|
212
|
+
value.nextCompactionAt,
|
|
213
|
+
].every((count) => count === undefined || isTokenCount(count)) &&
|
|
209
214
|
(value.error === undefined ||
|
|
210
215
|
(typeof value.error === "string" && value.error.length <= 10_000)));
|
|
211
216
|
if (!valid) throw new Error("Invalid compaction report");
|
package/worker/pi-compaction.ts
CHANGED
|
@@ -149,6 +149,7 @@ export class WorkerCompaction {
|
|
|
149
149
|
...(result.estimatedTokensAfter === undefined
|
|
150
150
|
? {}
|
|
151
151
|
: { tokensAfter: result.estimatedTokensAfter }),
|
|
152
|
+
...this.#contextAfter(),
|
|
152
153
|
...(model
|
|
153
154
|
? {
|
|
154
155
|
nextCompactionAt:
|
|
@@ -174,6 +175,12 @@ export class WorkerCompaction {
|
|
|
174
175
|
await this.#report(report);
|
|
175
176
|
}
|
|
176
177
|
|
|
178
|
+
/** The context the tiers measure after the compaction, system prompt and tools included. */
|
|
179
|
+
#contextAfter(): { contextAfter?: number } {
|
|
180
|
+
const latest = this.#tiers.latest();
|
|
181
|
+
return latest ? { contextAfter: latest.contextTokens } : {};
|
|
182
|
+
}
|
|
183
|
+
|
|
177
184
|
async #compact(
|
|
178
185
|
event: SessionBeforeCompactEvent,
|
|
179
186
|
): Promise<SessionBeforeCompactResult | undefined> {
|