pi-openai-toolkit 0.14.0 → 0.14.2
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/package.json +1 -1
- package/src/extension-runtime.ts +20 -3
package/package.json
CHANGED
package/src/extension-runtime.ts
CHANGED
|
@@ -781,7 +781,11 @@ export default function registerCompactionExtension(
|
|
|
781
781
|
const syncTools = async (ctx: ExtensionContext, model = ctx.model): Promise<boolean> => {
|
|
782
782
|
const config = dependencies.loadConfig().config.compaction;
|
|
783
783
|
const active = await isRemoteContextActive(ctx, config, model);
|
|
784
|
-
|
|
784
|
+
// sync() reports whether the tool-set update succeeded; an inactive model
|
|
785
|
+
// syncs fine and returns true. The activation decision must use `active`
|
|
786
|
+
// itself, or non-covered models would receive a window boundary.
|
|
787
|
+
const synced = tools.sync(active);
|
|
788
|
+
return active && synced;
|
|
785
789
|
};
|
|
786
790
|
pi.on("session_start", async (_event, ctx) => {
|
|
787
791
|
const active = await syncTools(ctx);
|
|
@@ -790,7 +794,9 @@ export default function registerCompactionExtension(
|
|
|
790
794
|
if (!config.enabled) return;
|
|
791
795
|
|
|
792
796
|
let activationReason: string | undefined;
|
|
793
|
-
|
|
797
|
+
// Only models the built-in Remote Context coverage targets may activate or
|
|
798
|
+
// warn; everything else silently runs Pi's normal compaction path.
|
|
799
|
+
if (config.contextManagement === "remote" && isCodexContextModel(ctx.model, config)) {
|
|
794
800
|
if (active) {
|
|
795
801
|
try {
|
|
796
802
|
contextWindows.ensureInitialized(pi, ctx, true);
|
|
@@ -847,7 +853,18 @@ export default function registerCompactionExtension(
|
|
|
847
853
|
tools.reset();
|
|
848
854
|
});
|
|
849
855
|
pi.on("model_select", async (event, ctx) => {
|
|
850
|
-
await syncTools(ctx, event.model);
|
|
856
|
+
const active = await syncTools(ctx, event.model);
|
|
857
|
+
// Switching into a covered model mid-session must open the window
|
|
858
|
+
// lifecycle immediately: without an identity the request rewrite skips
|
|
859
|
+
// window metadata, the backend never ingests those turns, and the first
|
|
860
|
+
// new_context would trim pre-switch history that no history can recover.
|
|
861
|
+
// ensureInitialized is idempotent when a window already exists.
|
|
862
|
+
if (!active) return;
|
|
863
|
+
try {
|
|
864
|
+
contextWindows.ensureInitialized(pi, ctx, true);
|
|
865
|
+
} catch {
|
|
866
|
+
notifyRemoteContextFailure(ctx, "malformed-window-state");
|
|
867
|
+
}
|
|
851
868
|
});
|
|
852
869
|
pi.on("before_agent_start", async (_event, ctx) => {
|
|
853
870
|
await syncTools(ctx);
|