pi-cache-optimizer 2.8.12 → 2.8.13

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.
Files changed (2) hide show
  1. package/index.ts +8 -3
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -1297,7 +1297,7 @@ function resolveActiveRouteSnapshot(
1297
1297
  model: PiModel | undefined,
1298
1298
  ctx?: Pick<ExtensionContext, "sessionManager">,
1299
1299
  ): PiRouteSnapshot | undefined {
1300
- if (!model) return undefined;
1300
+ if (!model || isNativeVirtualModel(model)) return undefined;
1301
1301
  const hint: PiRouteResolveHint | undefined = ctx ? { sessionIdHash: sessionHashFromContext(ctx) } : undefined;
1302
1302
 
1303
1303
  const adapter = getRoutingRegistry()?.getRouter(model.provider);
@@ -1519,7 +1519,10 @@ function getProviderPayloadModelId(payload: unknown): string | undefined {
1519
1519
  }
1520
1520
 
1521
1521
  function physicalModelsWithId(candidates: readonly PiModel[] | undefined, id: string): PiModel[] {
1522
- return (candidates ?? []).filter((candidate) => candidate.id === id && !isNativeVirtualModel(candidate));
1522
+ return (candidates ?? []).filter((candidate) => candidate.id === id
1523
+ && !isNativeVirtualModel(candidate)
1524
+ && !isRouterModel(candidate)
1525
+ && !getRoutingRegistry()?.getRouter(candidate.provider));
1523
1526
  }
1524
1527
 
1525
1528
  /**
@@ -11297,7 +11300,9 @@ export default function (pi: ExtensionAPI) {
11297
11300
  // model from the dispatched payload. Unresolved requests keep the virtual
11298
11301
  // model, which fails every identity-dependent mutation closed.
11299
11302
  const nativeVirtualRequest = resolveNativeVirtualRequestModel(ctx.model, event.payload, ctx, requestPolicyKey);
11300
- const requestModel = nativeVirtualRequest?.model ?? resolveRouteModel(ctx.model, ctx) ?? ctx.model;
11303
+ const requestModel = isNativeVirtualModel(ctx.model)
11304
+ ? (nativeVirtualRequest?.model ?? ctx.model)
11305
+ : (resolveRouteModel(ctx.model, ctx) ?? ctx.model);
11301
11306
  // Request-local identity is also needed by the always-on Anthropic TTL
11302
11307
  // validity repair, so retain the credential-blind snapshot even while the
11303
11308
  // optional runtime optimizer features are disabled.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cache-optimizer",
3
- "version": "2.8.12",
3
+ "version": "2.8.13",
4
4
  "description": "Improve Pi prompt/KV cache hit rates with stable prompts, OpenAI-compatible cache keys, proxy compat warnings, and footer cache stats.",
5
5
  "keywords": [
6
6
  "pi-package",