pi-cache-optimizer 2.6.20 → 2.6.21

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 +13 -1
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -1794,10 +1794,21 @@ function modelFromAssistantMessage(message: unknown, fallback: PiModel | undefin
1794
1794
  const api = firstNonEmptyString(record.api, fallback?.api) ?? "";
1795
1795
  if (!id || !provider) return fallback;
1796
1796
 
1797
+ const fallbackName = isNonEmptyString(fallback?.name) ? fallback.name : undefined;
1798
+ const preservesFallbackIdentity =
1799
+ !isVirtualRoutingModel(fallback) &&
1800
+ provider === fallback?.provider &&
1801
+ id === fallback?.id &&
1802
+ fallbackName !== undefined;
1803
+
1797
1804
  return {
1798
1805
  ...(fallback ?? {}),
1799
1806
  id,
1800
- name: id,
1807
+ // Direct providers such as kimi-coding may echo only a short model id
1808
+ // (`k3`) while the active model name (`Kimi K3`) carries the adapter token.
1809
+ // Preserve that display name only when response and fallback identities are
1810
+ // exactly the same; routed/different identities keep message-local naming.
1811
+ name: preservesFallbackIdentity ? fallbackName : id,
1801
1812
  provider,
1802
1813
  api,
1803
1814
  baseUrl: fallback?.baseUrl ?? "",
@@ -5954,6 +5965,7 @@ export const __internals_for_tests = {
5954
5965
  getAssistantMessageModelTokenValues,
5955
5966
  getCompat,
5956
5967
  modelKey,
5968
+ modelFromAssistantMessage,
5957
5969
  consolidateDirectProviderStatsModel,
5958
5970
  // Platform-friendly path helpers
5959
5971
  getAgentDirDisplayPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cache-optimizer",
3
- "version": "2.6.20",
3
+ "version": "2.6.21",
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",