pi-cache-optimizer 2.10.6 → 2.10.8

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 CHANGED
@@ -5,6 +5,22 @@ last version Pi recorded for this package under "Extension Updates". Pi records
5
5
  it sees this file, so notes start with the update after that.
6
6
  Older history is in the [git log](https://github.com/jiangge/pi-cache-optimizer/commits/master).
7
7
 
8
+ ## [2.10.8] - 2026-11-22
9
+
10
+ ### Fixed
11
+
12
+ - Native virtual models: when several credentialed providers share the routed model id and only some set `compat.promptCacheKeyMode: "disabled"`, the extension no longer adds a `prompt_cache_key` depending on catalog order; such requests are left unchanged. Providers whose mode is `"enabled"`, `"auto"` or unset are still treated alike. Thanks @qsgy-edge (#32).
13
+
14
+ ## [2.10.7] - 2026-11-21
15
+
16
+ ### Fixed
17
+
18
+ - Pi 1.6.0's built-in llama.cpp models are recognised again, so they no longer get proxy and session-affinity advice meant for third-party OpenAI-compatible gateways. Pi 1.6.0 stopped setting `compat.supportsDeveloperRole: false` on them. A same-id `llama.cpp` provider that sets cache or routing overrides (`promptCacheKeyMode`, `cacheControlFormat`, `openRouterRouting`, `vercelGatewayRouting`) is no longer treated as the built-in one.
19
+
20
+ ### Changed
21
+
22
+ - Validated against Pi 1.6.0. Its `models.json` compat keys are unchanged.
23
+
8
24
  ## [2.10.6] - 2026-11-13
9
25
 
10
26
  ### Changed
package/README.md CHANGED
@@ -64,7 +64,7 @@ Run `/reload` in Pi after install/update/remove so extension hooks refresh.
64
64
 
65
65
  On Pi 0.79.7 and newer, `pi update` updates Pi itself only. To update installed Pi packages such as this extension, run `pi update --extensions` (packages only) or `pi update --all` (Pi + packages).
66
66
 
67
- This extension requires Pi 0.82+ and is validated against Pi 1.5.2. It uses the official Pi package types directly for type-checking, along with extension hooks, `getAgentDir()`, and prompt options shared by those versions; it does not depend on Pi 0.83+ APIs such as `ctx.scopedModels` or the bundled TypeBox 1.3 aliases. Native virtual model support and codemode nested-call coalescing activate only on Pi 0.99+ hosts that produce them; older hosts keep the previous behavior. The local development baseline uses Node.js 22.19.0 or newer, matching Pi 1.0.3's engine requirement.
67
+ This extension requires Pi 0.82+ and is validated against Pi 1.6.0. It uses the official Pi package types directly for type-checking, along with extension hooks, `getAgentDir()`, and prompt options shared by those versions; it does not depend on Pi 0.83+ APIs such as `ctx.scopedModels` or the bundled TypeBox 1.3 aliases. Native virtual model support and codemode nested-call coalescing activate only on Pi 0.99+ hosts that produce them; older hosts keep the previous behavior. The local development baseline uses Node.js 22.19.0 or newer, matching Pi 1.0.3's engine requirement.
68
68
 
69
69
  ## Commands
70
70
 
package/README.zh-CN.md CHANGED
@@ -64,7 +64,7 @@ pi remove npm:pi-deepseek-cache-optimizer && pi install npm:pi-cache-optimizer
64
64
 
65
65
  Pi 0.79.7 及之后,`pi update` 默认只更新 Pi 本体。若要更新已安装的 Pi package(包括本扩展),请运行 `pi update --extensions`(只更新 packages)或 `pi update --all`(Pi 与 packages 一起更新)。
66
66
 
67
- 本扩展要求 Pi 0.82+,并已使用 Pi 1.5.2 验证。TypeScript 校验直接使用官方 Pi package 类型,同时只使用这些版本共有的 extension hooks、`getAgentDir()` 和 prompt options;不依赖 Pi 0.83+ 专有 API(例如 `ctx.scopedModels` 或 bundled TypeBox 1.3 aliases)。原生虚拟模型支持与 codemode 嵌套工具调用合并只在会产生它们的 Pi 0.99+ 上生效,较早版本保持原有行为。本地开发基线需要 Node.js 22.19.0 或更高版本,与 Pi 1.0.3 的 engine 要求一致。
67
+ 本扩展要求 Pi 0.82+,并已使用 Pi 1.6.0 验证。TypeScript 校验直接使用官方 Pi package 类型,同时只使用这些版本共有的 extension hooks、`getAgentDir()` 和 prompt options;不依赖 Pi 0.83+ 专有 API(例如 `ctx.scopedModels` 或 bundled TypeBox 1.3 aliases)。原生虚拟模型支持与 codemode 嵌套工具调用合并只在会产生它们的 Pi 0.99+ 上生效,较早版本保持原有行为。本地开发基线需要 Node.js 22.19.0 或更高版本,与 Pi 1.0.3 的 engine 要求一致。
68
68
 
69
69
  ## 命令
70
70
 
package/index.ts CHANGED
@@ -1698,6 +1698,10 @@ export default function (pi: ExtensionAPI) {
1698
1698
  promptCacheRetention400Models.has(key),
1699
1699
  anthropicTtlOrderErrorModels.has(key),
1700
1700
  isPromptCacheKeyOmittedForModel(model),
1701
+ // The decision, not the raw compat.promptCacheKeyMode: "enabled",
1702
+ // "auto" and an unset mode all inject, so only "disabled" may split
1703
+ // otherwise-equal candidates (PR #32).
1704
+ shouldInjectOpenAIPromptCacheKeyForModel(model),
1701
1705
  ]);
1702
1706
  }
1703
1707
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cache-optimizer",
3
- "version": "2.10.6",
3
+ "version": "2.10.8",
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",
@@ -38,7 +38,7 @@
38
38
  "check:modules": "node scripts/check-module-graph.mjs"
39
39
  },
40
40
  "devDependencies": {
41
- "@earendil-works/pi-coding-agent": "^1.5.2",
41
+ "@earendil-works/pi-coding-agent": "^1.6.0",
42
42
  "@earendil-works/pi-server": "^1.1.0",
43
43
  "@types/node": "^22.0.0",
44
44
  "jiti": "^2.7.0",
@@ -266,16 +266,23 @@ export function isPiBuiltInLlamaCppModel(model: PiModel | undefined): boolean {
266
266
  // cache/routing overrides, so provider id alone must never imply exemption.
267
267
  // supportsUsageInStreaming is deliberately not part of the fingerprint: Pi
268
268
  // 0.82.x sets it false and Pi 0.83+ sets it true after fixing streamed usage,
269
- // and it carries no routing or cache configuration.
269
+ // and it carries no routing or cache configuration. supportsDeveloperRole is
270
+ // false up to Pi 1.5.x; Pi 1.6.0 dropped it (developer role became
271
+ // api.openai.com-only by default), so absent is accepted too, but true is not.
270
272
  const compat = getCompat(model);
271
273
  return compat.supportsStore === false
272
- && compat.supportsDeveloperRole === false
274
+ && (compat.supportsDeveloperRole === false || compat.supportsDeveloperRole === undefined)
273
275
  && compat.supportsReasoningEffort === false
274
276
  && compat.supportsStrictMode === false
275
277
  && compat.maxTokensField === "max_tokens"
276
278
  && compat.sendSessionAffinityHeaders === undefined
277
279
  && compat.sessionAffinityFormat === undefined
278
- && compat.supportsLongCacheRetention === undefined;
280
+ && compat.supportsLongCacheRetention === undefined
281
+ // Cache/routing overrides Pi's built-in provider never sets.
282
+ && (compat as Record<string, unknown>).promptCacheKeyMode === undefined
283
+ && (compat as Record<string, unknown>).cacheControlFormat === undefined
284
+ && (compat as Record<string, unknown>).openRouterRouting === undefined
285
+ && (compat as Record<string, unknown>).vercelGatewayRouting === undefined;
279
286
  }
280
287
 
281
288
  export function isResponsesPromptRewriteBypassApi(api: unknown): boolean {
@@ -13,14 +13,14 @@ import { MODELS_JSON_PATH } from "./paths.ts";
13
13
  * key; unknown keys that resemble nothing are left alone so newer Pi fields
14
14
  * and personal annotations never produce noise. It never edits the file.
15
15
  *
16
- * Known key sets are copied from Pi 1.5.2 (1.4.0 added compat imageInput and sendImageOptInHeader; 1.5.0 changed no keys;
17
- * 1.5.1 added compat promptCacheKeyMode, requiresNonNullAssistantContent, requiresToolsWithToolHistory and supportsMessageThreads):
16
+ * Known key sets are copied from Pi 1.6.0 (1.4.0 added compat imageInput and sendImageOptInHeader; 1.5.0 changed no keys;
17
+ * 1.5.1 added compat promptCacheKeyMode, requiresNonNullAssistantContent, requiresToolsWithToolHistory and supportsMessageThreads; 1.6.0 changed no keys):
18
18
  * - @earendil-works/pi-coding-agent dist/core/model-config.js
19
19
  * (ModelsConfigSchema, ProviderConfigSchema, ModelDefinitionSchema, ModelOverrideSchema)
20
20
  * - @earendil-works/pi-ai dist/providers/compat-schema.js
21
21
  * (ProviderCompatSchema = merged properties of every per-API compat schema)
22
22
  */
23
- export const MODELS_JSON_SCHEMA_SOURCE_VERSION = "1.5.2";
23
+ export const MODELS_JSON_SCHEMA_SOURCE_VERSION = "1.6.0";
24
24
 
25
25
  export const MODELS_JSON_ROOT_KEYS: readonly string[] = ["$schema", "providers"];
26
26
 
@@ -38,7 +38,7 @@ export const MODELS_JSON_MODEL_OVERRIDE_KEYS: readonly string[] = [
38
38
  "contextWindow", "maxTokens", "samplingParams", "samplingParamsByThinkingLevel", "headers", "compat",
39
39
  ];
40
40
 
41
- /** Object.keys(ProviderCompatSchema.properties) in Pi 1.5.2, sorted. */
41
+ /** Object.keys(ProviderCompatSchema.properties) in Pi 1.6.0, sorted. */
42
42
  export const MODELS_JSON_COMPAT_KEYS: readonly string[] = [
43
43
  "allowEmptySignature", "allowedFallbackModels", "cacheControlFormat", "chatTemplateArgs", "chatTemplateKwargs",
44
44
  "forceAdaptiveThinking", "imageInput", "maxTokensField", "openRouterRouting", "promptCacheKeyMode",