johns-harness 2026.10.19 → 2026.10.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.
- package/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/dist/auth-profiles-5CHn7vq1.js +7 -5
- package/dist/compact-B247y5Qt.js +14 -5
- package/dist/config-koj5M_EO.js +7 -5
- package/dist/daemon-cli.js +7 -5
- package/dist/gateway-cli-B7fBU7gD.js +13 -8
- package/dist/gateway-cli-BCNMwzNq.js +13 -8
- package/dist/model-selection-BGlGpPgM.js +7 -5
- package/dist/model-selection-BU6wl1le.js +7 -5
- package/dist/model-selection-L7RMwsG-.js +7 -5
- package/dist/pi-embedded-C6ITuRXf.js +14 -5
- package/dist/pi-embedded-DoQsYfIY.js +14 -5
- package/dist/plugin-sdk/config-4Fgm-yEH.js +7 -5
- package/dist/plugin-sdk/config-Di-lyCdh.js +7 -5
- package/dist/plugin-sdk/discord.js +7 -5
- package/dist/plugin-sdk/dispatch-BP0viZiL.js +14 -5
- package/dist/plugin-sdk/dispatch-CQsjmw7g.js +14 -5
- package/dist/plugin-sdk/dispatch-Cerq29sy.js +14 -5
- package/dist/plugin-sdk/dispatch-Cndjtt0g.js +14 -5
- package/dist/plugin-sdk/dispatch-UogiJYul.js +14 -5
- package/dist/plugin-sdk/model-auth-CX9cPHdC.js +7 -5
- package/dist/plugin-sdk/model-auth-Ciehz0x5.js +7 -5
- package/dist/plugin-sdk/model-auth-DVyo6JSX.js +7 -5
- package/dist/plugin-sdk/model-auth-kiHYHGrs.js +7 -5
- package/dist/plugin-sdk/model-selection-Dbj4jDYM.js +7 -5
- package/dist/plugin-sdk/reply-DbZnH8-h.js +14 -5
- package/dist/reply-C5LKjXcC.js +14 -5
- package/dist/subscription-login.js +19 -2
- package/docs/PATCHES.md +65 -1
- package/docs/concepts/session-pruning.md +1 -1
- package/docs/providers/anthropic.md +7 -4
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +24 -12
- package/package.json +1 -1
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +24 -12
|
@@ -8469,16 +8469,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
8469
8469
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
8470
8470
|
let modelsMutated = false;
|
|
8471
8471
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
8472
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
8472
8473
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
8473
|
-
|
|
8474
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
8475
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
8474
8476
|
const current = entry ?? {};
|
|
8475
8477
|
const params = current.params ?? {};
|
|
8476
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
8478
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
8477
8479
|
nextModels[key] = {
|
|
8478
8480
|
...current,
|
|
8479
8481
|
params: {
|
|
8480
8482
|
...params,
|
|
8481
|
-
cacheRetention: "short"
|
|
8483
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
8482
8484
|
}
|
|
8483
8485
|
};
|
|
8484
8486
|
modelsMutated = true;
|
|
@@ -8490,12 +8492,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
8490
8492
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
8491
8493
|
const current = nextModels[key] ?? {};
|
|
8492
8494
|
const params = current.params ?? {};
|
|
8493
|
-
if (typeof params.cacheRetention !== "string") {
|
|
8495
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
8494
8496
|
nextModels[key] = {
|
|
8495
8497
|
...current,
|
|
8496
8498
|
params: {
|
|
8497
8499
|
...params,
|
|
8498
|
-
cacheRetention: "short"
|
|
8500
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
8499
8501
|
}
|
|
8500
8502
|
};
|
|
8501
8503
|
modelsMutated = true;
|
|
@@ -5594,16 +5594,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5594
5594
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
5595
5595
|
let modelsMutated = false;
|
|
5596
5596
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
5597
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
5597
5598
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
5598
|
-
|
|
5599
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
5600
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
5599
5601
|
const current = entry ?? {};
|
|
5600
5602
|
const params = current.params ?? {};
|
|
5601
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
5603
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
5602
5604
|
nextModels[key] = {
|
|
5603
5605
|
...current,
|
|
5604
5606
|
params: {
|
|
5605
5607
|
...params,
|
|
5606
|
-
cacheRetention: "short"
|
|
5608
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
5607
5609
|
}
|
|
5608
5610
|
};
|
|
5609
5611
|
modelsMutated = true;
|
|
@@ -5615,12 +5617,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5615
5617
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
5616
5618
|
const current = nextModels[key] ?? {};
|
|
5617
5619
|
const params = current.params ?? {};
|
|
5618
|
-
if (typeof params.cacheRetention !== "string") {
|
|
5620
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
5619
5621
|
nextModels[key] = {
|
|
5620
5622
|
...current,
|
|
5621
5623
|
params: {
|
|
5622
5624
|
...params,
|
|
5623
|
-
cacheRetention: "short"
|
|
5625
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
5624
5626
|
}
|
|
5625
5627
|
};
|
|
5626
5628
|
modelsMutated = true;
|
|
@@ -24292,7 +24292,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24292
24292
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24293
24293
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24294
24294
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24295
|
-
|
|
24295
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24296
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24297
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24296
24298
|
cfg: params.cfg,
|
|
24297
24299
|
store,
|
|
24298
24300
|
provider: providerKey,
|
|
@@ -34026,6 +34028,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34026
34028
|
provider: providerUsed,
|
|
34027
34029
|
model: modelUsed
|
|
34028
34030
|
});
|
|
34031
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34029
34032
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34030
34033
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34031
34034
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -82350,7 +82353,7 @@ function resolveExtraParams(params) {
|
|
|
82350
82353
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
82351
82354
|
* of the cacheRetention stream option.
|
|
82352
82355
|
*
|
|
82353
|
-
*
|
|
82356
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
82354
82357
|
*/
|
|
82355
82358
|
function resolveCacheRetention(extraParams, provider) {
|
|
82356
82359
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -82362,10 +82365,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
82362
82365
|
if (legacy === "5m") return "short";
|
|
82363
82366
|
if (legacy === "1h") return "long";
|
|
82364
82367
|
if (!isAnthropicDirect) return;
|
|
82365
|
-
return "
|
|
82368
|
+
return "long";
|
|
82366
82369
|
}
|
|
82367
82370
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
82368
|
-
|
|
82371
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
82372
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
82373
|
+
extraParams ??= {};
|
|
82369
82374
|
const streamParams = {};
|
|
82370
82375
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
82371
82376
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -88962,7 +88967,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
88962
88967
|
usage,
|
|
88963
88968
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
88964
88969
|
promptTokens,
|
|
88965
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
88970
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
88971
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
88966
88972
|
};
|
|
88967
88973
|
const payloads = buildEmbeddedRunPayloads({
|
|
88968
88974
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100355,6 +100361,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100355
100361
|
const patch = {
|
|
100356
100362
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100357
100363
|
model: params.modelUsed ?? entry.model,
|
|
100364
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100358
100365
|
contextTokens: resolvedContextTokens,
|
|
100359
100366
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100360
100367
|
updatedAt: Date.now()
|
|
@@ -100634,6 +100641,7 @@ function createFollowupRunner(params) {
|
|
|
100634
100641
|
promptTokens,
|
|
100635
100642
|
modelUsed,
|
|
100636
100643
|
providerUsed: fallbackProvider,
|
|
100644
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100637
100645
|
contextTokensUsed,
|
|
100638
100646
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100639
100647
|
logLabel: "followup"
|
|
@@ -100971,6 +100979,7 @@ async function runReplyAgent(params) {
|
|
|
100971
100979
|
promptTokens,
|
|
100972
100980
|
modelUsed,
|
|
100973
100981
|
providerUsed,
|
|
100982
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100974
100983
|
contextTokensUsed,
|
|
100975
100984
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100976
100985
|
cliSessionId
|
|
@@ -24401,7 +24401,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24401
24401
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24402
24402
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24403
24403
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24404
|
-
|
|
24404
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24405
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24406
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24405
24407
|
cfg: params.cfg,
|
|
24406
24408
|
store,
|
|
24407
24409
|
provider: providerKey,
|
|
@@ -34125,6 +34127,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34125
34127
|
provider: providerUsed,
|
|
34126
34128
|
model: modelUsed
|
|
34127
34129
|
});
|
|
34130
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34128
34131
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34129
34132
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34130
34133
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -82350,7 +82353,7 @@ function resolveExtraParams(params) {
|
|
|
82350
82353
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
82351
82354
|
* of the cacheRetention stream option.
|
|
82352
82355
|
*
|
|
82353
|
-
*
|
|
82356
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
82354
82357
|
*/
|
|
82355
82358
|
function resolveCacheRetention(extraParams, provider) {
|
|
82356
82359
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -82362,10 +82365,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
82362
82365
|
if (legacy === "5m") return "short";
|
|
82363
82366
|
if (legacy === "1h") return "long";
|
|
82364
82367
|
if (!isAnthropicDirect) return;
|
|
82365
|
-
return "
|
|
82368
|
+
return "long";
|
|
82366
82369
|
}
|
|
82367
82370
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
82368
|
-
|
|
82371
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
82372
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
82373
|
+
extraParams ??= {};
|
|
82369
82374
|
const streamParams = {};
|
|
82370
82375
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
82371
82376
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -88962,7 +88967,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
88962
88967
|
usage,
|
|
88963
88968
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
88964
88969
|
promptTokens,
|
|
88965
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
88970
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
88971
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
88966
88972
|
};
|
|
88967
88973
|
const payloads = buildEmbeddedRunPayloads({
|
|
88968
88974
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100355,6 +100361,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100355
100361
|
const patch = {
|
|
100356
100362
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100357
100363
|
model: params.modelUsed ?? entry.model,
|
|
100364
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100358
100365
|
contextTokens: resolvedContextTokens,
|
|
100359
100366
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100360
100367
|
updatedAt: Date.now()
|
|
@@ -100634,6 +100641,7 @@ function createFollowupRunner(params) {
|
|
|
100634
100641
|
promptTokens,
|
|
100635
100642
|
modelUsed,
|
|
100636
100643
|
providerUsed: fallbackProvider,
|
|
100644
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100637
100645
|
contextTokensUsed,
|
|
100638
100646
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100639
100647
|
logLabel: "followup"
|
|
@@ -100971,6 +100979,7 @@ async function runReplyAgent(params) {
|
|
|
100971
100979
|
promptTokens,
|
|
100972
100980
|
modelUsed,
|
|
100973
100981
|
providerUsed,
|
|
100982
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100974
100983
|
contextTokensUsed,
|
|
100975
100984
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100976
100985
|
cliSessionId
|
|
@@ -24985,7 +24985,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24985
24985
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24986
24986
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24987
24987
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24988
|
-
|
|
24988
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24989
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24990
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24989
24991
|
cfg: params.cfg,
|
|
24990
24992
|
store,
|
|
24991
24993
|
provider: providerKey,
|
|
@@ -34719,6 +34721,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34719
34721
|
provider: providerUsed,
|
|
34720
34722
|
model: modelUsed
|
|
34721
34723
|
});
|
|
34724
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34722
34725
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34723
34726
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34724
34727
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -82664,7 +82667,7 @@ function resolveExtraParams(params) {
|
|
|
82664
82667
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
82665
82668
|
* of the cacheRetention stream option.
|
|
82666
82669
|
*
|
|
82667
|
-
*
|
|
82670
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
82668
82671
|
*/
|
|
82669
82672
|
function resolveCacheRetention(extraParams, provider) {
|
|
82670
82673
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -82676,10 +82679,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
82676
82679
|
if (legacy === "5m") return "short";
|
|
82677
82680
|
if (legacy === "1h") return "long";
|
|
82678
82681
|
if (!isAnthropicDirect) return;
|
|
82679
|
-
return "
|
|
82682
|
+
return "long";
|
|
82680
82683
|
}
|
|
82681
82684
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
82682
|
-
|
|
82685
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
82686
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
82687
|
+
extraParams ??= {};
|
|
82683
82688
|
const streamParams = {};
|
|
82684
82689
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
82685
82690
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -89276,7 +89281,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
89276
89281
|
usage,
|
|
89277
89282
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
89278
89283
|
promptTokens,
|
|
89279
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
89284
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
89285
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
89280
89286
|
};
|
|
89281
89287
|
const payloads = buildEmbeddedRunPayloads({
|
|
89282
89288
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100669,6 +100675,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100669
100675
|
const patch = {
|
|
100670
100676
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100671
100677
|
model: params.modelUsed ?? entry.model,
|
|
100678
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100672
100679
|
contextTokens: resolvedContextTokens,
|
|
100673
100680
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100674
100681
|
updatedAt: Date.now()
|
|
@@ -100948,6 +100955,7 @@ function createFollowupRunner(params) {
|
|
|
100948
100955
|
promptTokens,
|
|
100949
100956
|
modelUsed,
|
|
100950
100957
|
providerUsed: fallbackProvider,
|
|
100958
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100951
100959
|
contextTokensUsed,
|
|
100952
100960
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100953
100961
|
logLabel: "followup"
|
|
@@ -101285,6 +101293,7 @@ async function runReplyAgent(params) {
|
|
|
101285
101293
|
promptTokens,
|
|
101286
101294
|
modelUsed,
|
|
101287
101295
|
providerUsed,
|
|
101296
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
101288
101297
|
contextTokensUsed,
|
|
101289
101298
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
101290
101299
|
cliSessionId
|
|
@@ -24666,7 +24666,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24666
24666
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24667
24667
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24668
24668
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24669
|
-
|
|
24669
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24670
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24671
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24670
24672
|
cfg: params.cfg,
|
|
24671
24673
|
store,
|
|
24672
24674
|
provider: providerKey,
|
|
@@ -34390,6 +34392,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34390
34392
|
provider: providerUsed,
|
|
34391
34393
|
model: modelUsed
|
|
34392
34394
|
});
|
|
34395
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34393
34396
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34394
34397
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34395
34398
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -82391,7 +82394,7 @@ function resolveExtraParams(params) {
|
|
|
82391
82394
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
82392
82395
|
* of the cacheRetention stream option.
|
|
82393
82396
|
*
|
|
82394
|
-
*
|
|
82397
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
82395
82398
|
*/
|
|
82396
82399
|
function resolveCacheRetention(extraParams, provider) {
|
|
82397
82400
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -82403,10 +82406,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
82403
82406
|
if (legacy === "5m") return "short";
|
|
82404
82407
|
if (legacy === "1h") return "long";
|
|
82405
82408
|
if (!isAnthropicDirect) return;
|
|
82406
|
-
return "
|
|
82409
|
+
return "long";
|
|
82407
82410
|
}
|
|
82408
82411
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
82409
|
-
|
|
82412
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
82413
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
82414
|
+
extraParams ??= {};
|
|
82410
82415
|
const streamParams = {};
|
|
82411
82416
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
82412
82417
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -89003,7 +89008,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
89003
89008
|
usage,
|
|
89004
89009
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
89005
89010
|
promptTokens,
|
|
89006
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
89011
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
89012
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
89007
89013
|
};
|
|
89008
89014
|
const payloads = buildEmbeddedRunPayloads({
|
|
89009
89015
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100396,6 +100402,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100396
100402
|
const patch = {
|
|
100397
100403
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100398
100404
|
model: params.modelUsed ?? entry.model,
|
|
100405
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100399
100406
|
contextTokens: resolvedContextTokens,
|
|
100400
100407
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100401
100408
|
updatedAt: Date.now()
|
|
@@ -100675,6 +100682,7 @@ function createFollowupRunner(params) {
|
|
|
100675
100682
|
promptTokens,
|
|
100676
100683
|
modelUsed,
|
|
100677
100684
|
providerUsed: fallbackProvider,
|
|
100685
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100678
100686
|
contextTokensUsed,
|
|
100679
100687
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100680
100688
|
logLabel: "followup"
|
|
@@ -101012,6 +101020,7 @@ async function runReplyAgent(params) {
|
|
|
101012
101020
|
promptTokens,
|
|
101013
101021
|
modelUsed,
|
|
101014
101022
|
providerUsed,
|
|
101023
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
101015
101024
|
contextTokensUsed,
|
|
101016
101025
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
101017
101026
|
cliSessionId
|
|
@@ -24579,7 +24579,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24579
24579
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24580
24580
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24581
24581
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24582
|
-
|
|
24582
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24583
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24584
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24583
24585
|
cfg: params.cfg,
|
|
24584
24586
|
store,
|
|
24585
24587
|
provider: providerKey,
|
|
@@ -34313,6 +34315,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34313
34315
|
provider: providerUsed,
|
|
34314
34316
|
model: modelUsed
|
|
34315
34317
|
});
|
|
34318
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34316
34319
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34317
34320
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34318
34321
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -82350,7 +82353,7 @@ function resolveExtraParams(params) {
|
|
|
82350
82353
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
82351
82354
|
* of the cacheRetention stream option.
|
|
82352
82355
|
*
|
|
82353
|
-
*
|
|
82356
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
82354
82357
|
*/
|
|
82355
82358
|
function resolveCacheRetention(extraParams, provider) {
|
|
82356
82359
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -82362,10 +82365,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
82362
82365
|
if (legacy === "5m") return "short";
|
|
82363
82366
|
if (legacy === "1h") return "long";
|
|
82364
82367
|
if (!isAnthropicDirect) return;
|
|
82365
|
-
return "
|
|
82368
|
+
return "long";
|
|
82366
82369
|
}
|
|
82367
82370
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
82368
|
-
|
|
82371
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
82372
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
82373
|
+
extraParams ??= {};
|
|
82369
82374
|
const streamParams = {};
|
|
82370
82375
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
82371
82376
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -88962,7 +88967,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
88962
88967
|
usage,
|
|
88963
88968
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
88964
88969
|
promptTokens,
|
|
88965
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
88970
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
88971
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
88966
88972
|
};
|
|
88967
88973
|
const payloads = buildEmbeddedRunPayloads({
|
|
88968
88974
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100355,6 +100361,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100355
100361
|
const patch = {
|
|
100356
100362
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100357
100363
|
model: params.modelUsed ?? entry.model,
|
|
100364
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100358
100365
|
contextTokens: resolvedContextTokens,
|
|
100359
100366
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100360
100367
|
updatedAt: Date.now()
|
|
@@ -100634,6 +100641,7 @@ function createFollowupRunner(params) {
|
|
|
100634
100641
|
promptTokens,
|
|
100635
100642
|
modelUsed,
|
|
100636
100643
|
providerUsed: fallbackProvider,
|
|
100644
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100637
100645
|
contextTokensUsed,
|
|
100638
100646
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100639
100647
|
logLabel: "followup"
|
|
@@ -100971,6 +100979,7 @@ async function runReplyAgent(params) {
|
|
|
100971
100979
|
promptTokens,
|
|
100972
100980
|
modelUsed,
|
|
100973
100981
|
providerUsed,
|
|
100982
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100974
100983
|
contextTokensUsed,
|
|
100975
100984
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100976
100985
|
cliSessionId
|
|
@@ -6386,16 +6386,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
6386
6386
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
6387
6387
|
let modelsMutated = false;
|
|
6388
6388
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
6389
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
6389
6390
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
6390
|
-
|
|
6391
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
6392
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
6391
6393
|
const current = entry ?? {};
|
|
6392
6394
|
const params = current.params ?? {};
|
|
6393
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
6395
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
6394
6396
|
nextModels[key] = {
|
|
6395
6397
|
...current,
|
|
6396
6398
|
params: {
|
|
6397
6399
|
...params,
|
|
6398
|
-
cacheRetention: "short"
|
|
6400
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
6399
6401
|
}
|
|
6400
6402
|
};
|
|
6401
6403
|
modelsMutated = true;
|
|
@@ -6407,12 +6409,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
6407
6409
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
6408
6410
|
const current = nextModels[key] ?? {};
|
|
6409
6411
|
const params = current.params ?? {};
|
|
6410
|
-
if (typeof params.cacheRetention !== "string") {
|
|
6412
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
6411
6413
|
nextModels[key] = {
|
|
6412
6414
|
...current,
|
|
6413
6415
|
params: {
|
|
6414
6416
|
...params,
|
|
6415
|
-
cacheRetention: "short"
|
|
6417
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
6416
6418
|
}
|
|
6417
6419
|
};
|
|
6418
6420
|
modelsMutated = true;
|
|
@@ -5355,16 +5355,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5355
5355
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
5356
5356
|
let modelsMutated = false;
|
|
5357
5357
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
5358
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
5358
5359
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
5359
|
-
|
|
5360
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
5361
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
5360
5362
|
const current = entry ?? {};
|
|
5361
5363
|
const params = current.params ?? {};
|
|
5362
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
5364
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
5363
5365
|
nextModels[key] = {
|
|
5364
5366
|
...current,
|
|
5365
5367
|
params: {
|
|
5366
5368
|
...params,
|
|
5367
|
-
cacheRetention: "short"
|
|
5369
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
5368
5370
|
}
|
|
5369
5371
|
};
|
|
5370
5372
|
modelsMutated = true;
|
|
@@ -5376,12 +5378,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5376
5378
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
5377
5379
|
const current = nextModels[key] ?? {};
|
|
5378
5380
|
const params = current.params ?? {};
|
|
5379
|
-
if (typeof params.cacheRetention !== "string") {
|
|
5381
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
5380
5382
|
nextModels[key] = {
|
|
5381
5383
|
...current,
|
|
5382
5384
|
params: {
|
|
5383
5385
|
...params,
|
|
5384
|
-
cacheRetention: "short"
|
|
5386
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
5385
5387
|
}
|
|
5386
5388
|
};
|
|
5387
5389
|
modelsMutated = true;
|
|
@@ -5359,16 +5359,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5359
5359
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
5360
5360
|
let modelsMutated = false;
|
|
5361
5361
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
5362
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
5362
5363
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
5363
|
-
|
|
5364
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
5365
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
5364
5366
|
const current = entry ?? {};
|
|
5365
5367
|
const params = current.params ?? {};
|
|
5366
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
5368
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
5367
5369
|
nextModels[key] = {
|
|
5368
5370
|
...current,
|
|
5369
5371
|
params: {
|
|
5370
5372
|
...params,
|
|
5371
|
-
cacheRetention: "short"
|
|
5373
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
5372
5374
|
}
|
|
5373
5375
|
};
|
|
5374
5376
|
modelsMutated = true;
|
|
@@ -5380,12 +5382,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5380
5382
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
5381
5383
|
const current = nextModels[key] ?? {};
|
|
5382
5384
|
const params = current.params ?? {};
|
|
5383
|
-
if (typeof params.cacheRetention !== "string") {
|
|
5385
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
5384
5386
|
nextModels[key] = {
|
|
5385
5387
|
...current,
|
|
5386
5388
|
params: {
|
|
5387
5389
|
...params,
|
|
5388
|
-
cacheRetention: "short"
|
|
5390
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
5389
5391
|
}
|
|
5390
5392
|
};
|
|
5391
5393
|
modelsMutated = true;
|
|
@@ -5359,16 +5359,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5359
5359
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
5360
5360
|
let modelsMutated = false;
|
|
5361
5361
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
5362
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
5362
5363
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
5363
|
-
|
|
5364
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
5365
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
5364
5366
|
const current = entry ?? {};
|
|
5365
5367
|
const params = current.params ?? {};
|
|
5366
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
5368
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
5367
5369
|
nextModels[key] = {
|
|
5368
5370
|
...current,
|
|
5369
5371
|
params: {
|
|
5370
5372
|
...params,
|
|
5371
|
-
cacheRetention: "short"
|
|
5373
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
5372
5374
|
}
|
|
5373
5375
|
};
|
|
5374
5376
|
modelsMutated = true;
|
|
@@ -5380,12 +5382,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5380
5382
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
5381
5383
|
const current = nextModels[key] ?? {};
|
|
5382
5384
|
const params = current.params ?? {};
|
|
5383
|
-
if (typeof params.cacheRetention !== "string") {
|
|
5385
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
5384
5386
|
nextModels[key] = {
|
|
5385
5387
|
...current,
|
|
5386
5388
|
params: {
|
|
5387
5389
|
...params,
|
|
5388
|
-
cacheRetention: "short"
|
|
5390
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
5389
5391
|
}
|
|
5390
5392
|
};
|
|
5391
5393
|
modelsMutated = true;
|
|
@@ -5167,16 +5167,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5167
5167
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
5168
5168
|
let modelsMutated = false;
|
|
5169
5169
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
5170
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
5170
5171
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
5171
|
-
|
|
5172
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
5173
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
5172
5174
|
const current = entry ?? {};
|
|
5173
5175
|
const params = current.params ?? {};
|
|
5174
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
5176
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
5175
5177
|
nextModels[key] = {
|
|
5176
5178
|
...current,
|
|
5177
5179
|
params: {
|
|
5178
5180
|
...params,
|
|
5179
|
-
cacheRetention: "short"
|
|
5181
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
5180
5182
|
}
|
|
5181
5183
|
};
|
|
5182
5184
|
modelsMutated = true;
|
|
@@ -5188,12 +5190,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5188
5190
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
5189
5191
|
const current = nextModels[key] ?? {};
|
|
5190
5192
|
const params = current.params ?? {};
|
|
5191
|
-
if (typeof params.cacheRetention !== "string") {
|
|
5193
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
5192
5194
|
nextModels[key] = {
|
|
5193
5195
|
...current,
|
|
5194
5196
|
params: {
|
|
5195
5197
|
...params,
|
|
5196
|
-
cacheRetention: "short"
|
|
5198
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
5197
5199
|
}
|
|
5198
5200
|
};
|
|
5199
5201
|
modelsMutated = true;
|