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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026.10.21
|
|
4
|
+
|
|
5
|
+
- **One-hour prompt caching is the Anthropic default**, for both API keys and Claude subscriptions, including models with no params configured. This avoids rewriting a large cached prompt after gaps longer than five minutes. Explicit `none`, `short`, `long` and legacy `cacheControlTtl` settings still win; Bedrock behavior is unchanged.
|
|
6
|
+
- **The wire request matches the policy:** the adapter sends `cache_control: { type: "ephemeral", ttl: "1h" }` on the existing Anthropic cache breakpoints and adds the extended-cache beta on both auth paths, even with custom beta headers. Stable system content stays cached, changing memory stays outside that breakpoint, and subscription attribution and plan-limit routing are preserved.
|
|
7
|
+
- **Live proof, after gaps over six minutes:** API cache read/write went from 0/31,332 to 31,332/61; subscription from 0/31,407 to 31,407/61. Both subscription responses returned `anthropic-ratelimit-unified-5h-status: allowed`, with Extra usage still disabled. All cache writes were one-hour writes.
|
|
8
|
+
- **Validation:** 36 new Family 90 tests cover all ten runtime and fourteen config copies, actual adapter SSE requests for both auth modes, explicit/legacy settings, empty params, header merging and replay safety. Verifier 564/564; full suite 1,249 pass and 5 existing skips. Clean 2026.10.20 replay matches all 25 changed runtime/adapter files byte for byte.
|
|
9
|
+
- **Rollback:** `npm i -g johns-harness@2026.10.20`.
|
|
10
|
+
|
|
11
|
+
## 2026.10.20
|
|
12
|
+
|
|
13
|
+
- **A subscription login takes effect on the very next turn.** After `/login claude` or `/login chatgpt` (chat or CLI), the matching subscription serves the next turn of every existing session with no `johnness secrets reload`, no `/new` and no restart. Root cause: the gateway serves turns from an in-memory auth snapshot taken at start, and a login wrote `auth-profiles.json` without replacing it, so the picker never saw the new profile until a reload. The login now refreshes that snapshot: in process when the login runs inside the gateway, over the `secrets.reload` RPC when it runs from the CLI; no gateway running is fine.
|
|
14
|
+
- **`/status` names the profile that actually served the last turn** (`authProfileServed`), ahead of any stale override, so the card says "oauth (anthropic:subscription)" when the subscription ran and "api-key" when the API key did.
|
|
15
|
+
- **Validation:** Family 89 exact replay from a clean checkout (13 files byte-identical), picker trigger across all ten reply bundles, refresh paths, status label, strip and re-layer with Families 86 to 88, and an end-to-end test against an isolated gateway: API key on turn one, a control save without the refresh still on the API key, then the real save and the next turn of the same session on the subscription bearer token. 557 verifier checks, full suite.
|
|
16
|
+
- **Rollback:** `npm i -g johns-harness@2026.10.19`.
|
|
17
|
+
|
|
3
18
|
## 2026.10.19
|
|
4
19
|
|
|
5
20
|
- **Claude subscription turns now draw from the plan's included limits, not extra usage.** John's requirement: "I don't want it to use extra usage, I want it to use the real subscription. Make it emulate Claude code if necessary." Anthropic decides per request, from content, whether a subscription turn is first party (plan limits) or third party (the organization's Extra usage). The harness prompt plus its tool list scored as third party, so with Extra usage off every turn was HTTP 400 and fell back to the API key. Real Claude Code 2.1.292 was captured on the wire and 2.1.304 was read from the binary: Claude Code sends an attribution system block first, `x-anthropic-billing-header: cc_version=<version>.<hash>; cc_entrypoint=sdk-cli; cch=00000;`, then its identity line. With that block first, the full harness prompt and 28 tools are served from plan limits.
|
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Send `/login` to list subscription choices. Use `/login chatgpt` (or `/login gpt
|
|
|
51
51
|
|
|
52
52
|
For **ChatGPT**, open the link, sign in, enter the device code on that page and tap Approve. In Telegram, tap the code to copy it. Enable "Device code authorization for Codex" once in chatgpt.com > Settings > Security; then send `/login chatgpt` for a fresh code. The existing device flow is unchanged.
|
|
53
53
|
|
|
54
|
-
For **Claude**, open the link, sign in to your subscription account, approve, then copy the complete code (including `#state`) from the callback page. Send `/login claude <complete code>` in the same chat. This uses the Claude Code OAuth client and request envelope, not a new third-party Anthropic client. Eligible Pro, Max and Team accounts use subscription limits first, with your existing Anthropic API-key profile as fallback on rate limits, authentication failures or quota exhaustion. Subscription turns record $0; API fallback turns keep normal API pricing. Tokens refresh automatically. Sign-in does not edit gateway configuration. Subscription turns are served from your plan's included limits: the adapter sends Claude Code's own request attribution (the same first system block and Agent SDK identity line Claude Code sends), so the full harness prompt and tools are not billed as third-party extra usage. If Anthropic ever answers "Third-party apps now draw from extra usage", the harness falls back to the API key on that turn.
|
|
54
|
+
For **Claude**, open the link, sign in to your subscription account, approve, then copy the complete code (including `#state`) from the callback page. Send `/login claude <complete code>` in the same chat. This uses the Claude Code OAuth client and request envelope, not a new third-party Anthropic client. Eligible Pro, Max and Team accounts use subscription limits first, with your existing Anthropic API-key profile as fallback on rate limits, authentication failures or quota exhaustion. Subscription turns record $0; API fallback turns keep normal API pricing. Tokens refresh automatically. Sign-in does not edit gateway configuration. Subscription turns are served from your plan's included limits: the adapter sends Claude Code's own request attribution (the same first system block and Agent SDK identity line Claude Code sends), so the full harness prompt and tools are not billed as third-party extra usage. If Anthropic ever answers "Third-party apps now draw from extra usage", the harness falls back to the API key on that turn. A login takes effect on the very next turn of every existing session; `/status` shows the profile that served the last turn.
|
|
55
55
|
|
|
56
56
|
In a terminal, run `johnness login` to list choices, `johnness login chatgpt` or `johnness login claude`. Claude opens the browser and asks for the complete code; use `--no-browser` on a remote host to print the link instead. The equivalent commands are `johnness models auth login chatgpt` and `johnness models auth login claude`. Existing `johnness models auth login --device` remains a ChatGPT shortcut.
|
|
57
57
|
|
|
@@ -5520,16 +5520,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5520
5520
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
5521
5521
|
let modelsMutated = false;
|
|
5522
5522
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
5523
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
5523
5524
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
5524
|
-
|
|
5525
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
5526
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
5525
5527
|
const current = entry ?? {};
|
|
5526
5528
|
const params = current.params ?? {};
|
|
5527
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
5529
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
5528
5530
|
nextModels[key] = {
|
|
5529
5531
|
...current,
|
|
5530
5532
|
params: {
|
|
5531
5533
|
...params,
|
|
5532
|
-
cacheRetention: "short"
|
|
5534
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
5533
5535
|
}
|
|
5534
5536
|
};
|
|
5535
5537
|
modelsMutated = true;
|
|
@@ -5541,12 +5543,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5541
5543
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
5542
5544
|
const current = nextModels[key] ?? {};
|
|
5543
5545
|
const params = current.params ?? {};
|
|
5544
|
-
if (typeof params.cacheRetention !== "string") {
|
|
5546
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
5545
5547
|
nextModels[key] = {
|
|
5546
5548
|
...current,
|
|
5547
5549
|
params: {
|
|
5548
5550
|
...params,
|
|
5549
|
-
cacheRetention: "short"
|
|
5551
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
5550
5552
|
}
|
|
5551
5553
|
};
|
|
5552
5554
|
modelsMutated = true;
|
package/dist/compact-B247y5Qt.js
CHANGED
|
@@ -6430,7 +6430,7 @@ function resolveExtraParams(params) {
|
|
|
6430
6430
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
6431
6431
|
* of the cacheRetention stream option.
|
|
6432
6432
|
*
|
|
6433
|
-
*
|
|
6433
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
6434
6434
|
*/
|
|
6435
6435
|
function resolveCacheRetention(extraParams, provider) {
|
|
6436
6436
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -6442,10 +6442,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
6442
6442
|
if (legacy === "5m") return "short";
|
|
6443
6443
|
if (legacy === "1h") return "long";
|
|
6444
6444
|
if (!isAnthropicDirect) return;
|
|
6445
|
-
return "
|
|
6445
|
+
return "long";
|
|
6446
6446
|
}
|
|
6447
6447
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
6448
|
-
|
|
6448
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
6449
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
6450
|
+
extraParams ??= {};
|
|
6449
6451
|
const streamParams = {};
|
|
6450
6452
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
6451
6453
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -19078,7 +19080,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
19078
19080
|
usage,
|
|
19079
19081
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
19080
19082
|
promptTokens,
|
|
19081
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
19083
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
19084
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
19082
19085
|
};
|
|
19083
19086
|
const payloads = buildEmbeddedRunPayloads({
|
|
19084
19087
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -35895,7 +35898,9 @@ function resolveModelAuthLabel(params) {
|
|
|
35895
35898
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
35896
35899
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
35897
35900
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
35898
|
-
|
|
35901
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
35902
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
35903
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
35899
35904
|
cfg: params.cfg,
|
|
35900
35905
|
store,
|
|
35901
35906
|
provider: providerKey,
|
|
@@ -58645,6 +58650,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
58645
58650
|
const patch = {
|
|
58646
58651
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
58647
58652
|
model: params.modelUsed ?? entry.model,
|
|
58653
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
58648
58654
|
contextTokens: resolvedContextTokens,
|
|
58649
58655
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
58650
58656
|
updatedAt: Date.now()
|
|
@@ -58924,6 +58930,7 @@ function createFollowupRunner(params) {
|
|
|
58924
58930
|
promptTokens,
|
|
58925
58931
|
modelUsed,
|
|
58926
58932
|
providerUsed: fallbackProvider,
|
|
58933
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
58927
58934
|
contextTokensUsed,
|
|
58928
58935
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
58929
58936
|
logLabel: "followup"
|
|
@@ -59261,6 +59268,7 @@ async function runReplyAgent(params) {
|
|
|
59261
59268
|
promptTokens,
|
|
59262
59269
|
modelUsed,
|
|
59263
59270
|
providerUsed,
|
|
59271
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
59264
59272
|
contextTokensUsed,
|
|
59265
59273
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
59266
59274
|
cliSessionId
|
|
@@ -72254,6 +72262,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
72254
72262
|
provider: providerUsed,
|
|
72255
72263
|
model: modelUsed
|
|
72256
72264
|
});
|
|
72265
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
72257
72266
|
if (isCliProvider(providerUsed, cfg)) {
|
|
72258
72267
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
72259
72268
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
package/dist/config-koj5M_EO.js
CHANGED
|
@@ -2214,16 +2214,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
2214
2214
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
2215
2215
|
let modelsMutated = false;
|
|
2216
2216
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
2217
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
2217
2218
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
2218
|
-
|
|
2219
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
2220
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
2219
2221
|
const current = entry ?? {};
|
|
2220
2222
|
const params = current.params ?? {};
|
|
2221
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
2223
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
2222
2224
|
nextModels[key] = {
|
|
2223
2225
|
...current,
|
|
2224
2226
|
params: {
|
|
2225
2227
|
...params,
|
|
2226
|
-
cacheRetention: "short"
|
|
2228
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
2227
2229
|
}
|
|
2228
2230
|
};
|
|
2229
2231
|
modelsMutated = true;
|
|
@@ -2235,12 +2237,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
2235
2237
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
2236
2238
|
const current = nextModels[key] ?? {};
|
|
2237
2239
|
const params = current.params ?? {};
|
|
2238
|
-
if (typeof params.cacheRetention !== "string") {
|
|
2240
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
2239
2241
|
nextModels[key] = {
|
|
2240
2242
|
...current,
|
|
2241
2243
|
params: {
|
|
2242
2244
|
...params,
|
|
2243
|
-
cacheRetention: "short"
|
|
2245
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
2244
2246
|
}
|
|
2245
2247
|
};
|
|
2246
2248
|
modelsMutated = true;
|
package/dist/daemon-cli.js
CHANGED
|
@@ -5366,16 +5366,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5366
5366
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
5367
5367
|
let modelsMutated = false;
|
|
5368
5368
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
5369
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
5369
5370
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
5370
|
-
|
|
5371
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
5372
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
5371
5373
|
const current = entry ?? {};
|
|
5372
5374
|
const params = current.params ?? {};
|
|
5373
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
5375
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
5374
5376
|
nextModels[key] = {
|
|
5375
5377
|
...current,
|
|
5376
5378
|
params: {
|
|
5377
5379
|
...params,
|
|
5378
|
-
cacheRetention: "short"
|
|
5380
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
5379
5381
|
}
|
|
5380
5382
|
};
|
|
5381
5383
|
modelsMutated = true;
|
|
@@ -5387,12 +5389,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
5387
5389
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
5388
5390
|
const current = nextModels[key] ?? {};
|
|
5389
5391
|
const params = current.params ?? {};
|
|
5390
|
-
if (typeof params.cacheRetention !== "string") {
|
|
5392
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
5391
5393
|
nextModels[key] = {
|
|
5392
5394
|
...current,
|
|
5393
5395
|
params: {
|
|
5394
5396
|
...params,
|
|
5395
|
-
cacheRetention: "short"
|
|
5397
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
5396
5398
|
}
|
|
5397
5399
|
};
|
|
5398
5400
|
modelsMutated = true;
|
|
@@ -23859,15 +23859,19 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
23859
23859
|
})().catch((err) => log.error(`Delivery recovery failed: ${String(err)}`));
|
|
23860
23860
|
const execApprovalManager = new ExecApprovalManager();
|
|
23861
23861
|
const execApprovalHandlers = createExecApprovalHandlers(execApprovalManager, { forwarder: createExecApprovalForwarder() });
|
|
23862
|
+
const reloadRuntimeSecrets = async () => {
|
|
23863
|
+
const active = getActiveSecretsRuntimeSnapshot();
|
|
23864
|
+
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23865
|
+
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23866
|
+
reason: "reload",
|
|
23867
|
+
activate: true
|
|
23868
|
+
})).warnings.length };
|
|
23869
|
+
};
|
|
23870
|
+
/* JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: a subscription login inside this process (chat /login) refreshes the
|
|
23871
|
+
runtime auth snapshot through this hook, the same path as the secrets.reload RPC. */
|
|
23872
|
+
globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] = reloadRuntimeSecrets;
|
|
23862
23873
|
const secretsHandlers = createSecretsHandlers({
|
|
23863
|
-
reloadSecrets:
|
|
23864
|
-
const active = getActiveSecretsRuntimeSnapshot();
|
|
23865
|
-
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23866
|
-
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23867
|
-
reason: "reload",
|
|
23868
|
-
activate: true
|
|
23869
|
-
})).warnings.length };
|
|
23870
|
-
},
|
|
23874
|
+
reloadSecrets: reloadRuntimeSecrets,
|
|
23871
23875
|
resolveSecrets: async ({ commandName, targetIds }) => {
|
|
23872
23876
|
const { assignments, diagnostics, inactiveRefPaths } = resolveCommandSecretsFromActiveRuntimeSnapshot({
|
|
23873
23877
|
commandName,
|
|
@@ -24107,6 +24111,7 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
24107
24111
|
browserAuthRateLimiter.dispose();
|
|
24108
24112
|
channelHealthMonitor?.stop();
|
|
24109
24113
|
clearSecretsRuntimeSnapshot();
|
|
24114
|
+
if (globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] === reloadRuntimeSecrets) delete globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')];
|
|
24110
24115
|
await close(opts);
|
|
24111
24116
|
} };
|
|
24112
24117
|
}
|
|
@@ -23861,15 +23861,19 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
23861
23861
|
})().catch((err) => log.error(`Delivery recovery failed: ${String(err)}`));
|
|
23862
23862
|
const execApprovalManager = new ExecApprovalManager();
|
|
23863
23863
|
const execApprovalHandlers = createExecApprovalHandlers(execApprovalManager, { forwarder: createExecApprovalForwarder() });
|
|
23864
|
+
const reloadRuntimeSecrets = async () => {
|
|
23865
|
+
const active = getActiveSecretsRuntimeSnapshot();
|
|
23866
|
+
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23867
|
+
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23868
|
+
reason: "reload",
|
|
23869
|
+
activate: true
|
|
23870
|
+
})).warnings.length };
|
|
23871
|
+
};
|
|
23872
|
+
/* JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: a subscription login inside this process (chat /login) refreshes the
|
|
23873
|
+
runtime auth snapshot through this hook, the same path as the secrets.reload RPC. */
|
|
23874
|
+
globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] = reloadRuntimeSecrets;
|
|
23864
23875
|
const secretsHandlers = createSecretsHandlers({
|
|
23865
|
-
reloadSecrets:
|
|
23866
|
-
const active = getActiveSecretsRuntimeSnapshot();
|
|
23867
|
-
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23868
|
-
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23869
|
-
reason: "reload",
|
|
23870
|
-
activate: true
|
|
23871
|
-
})).warnings.length };
|
|
23872
|
-
},
|
|
23876
|
+
reloadSecrets: reloadRuntimeSecrets,
|
|
23873
23877
|
resolveSecrets: async ({ commandName, targetIds }) => {
|
|
23874
23878
|
const { assignments, diagnostics, inactiveRefPaths } = resolveCommandSecretsFromActiveRuntimeSnapshot({
|
|
23875
23879
|
commandName,
|
|
@@ -24109,6 +24113,7 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
24109
24113
|
browserAuthRateLimiter.dispose();
|
|
24110
24114
|
channelHealthMonitor?.stop();
|
|
24111
24115
|
clearSecretsRuntimeSnapshot();
|
|
24116
|
+
if (globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] === reloadRuntimeSecrets) delete globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')];
|
|
24112
24117
|
await close(opts);
|
|
24113
24118
|
} };
|
|
24114
24119
|
}
|
|
@@ -2091,16 +2091,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
2091
2091
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
2092
2092
|
let modelsMutated = false;
|
|
2093
2093
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
2094
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
2094
2095
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
2095
|
-
|
|
2096
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
2097
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
2096
2098
|
const current = entry ?? {};
|
|
2097
2099
|
const params = current.params ?? {};
|
|
2098
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
2100
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
2099
2101
|
nextModels[key] = {
|
|
2100
2102
|
...current,
|
|
2101
2103
|
params: {
|
|
2102
2104
|
...params,
|
|
2103
|
-
cacheRetention: "short"
|
|
2105
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
2104
2106
|
}
|
|
2105
2107
|
};
|
|
2106
2108
|
modelsMutated = true;
|
|
@@ -2112,12 +2114,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
2112
2114
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
2113
2115
|
const current = nextModels[key] ?? {};
|
|
2114
2116
|
const params = current.params ?? {};
|
|
2115
|
-
if (typeof params.cacheRetention !== "string") {
|
|
2117
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
2116
2118
|
nextModels[key] = {
|
|
2117
2119
|
...current,
|
|
2118
2120
|
params: {
|
|
2119
2121
|
...params,
|
|
2120
|
-
cacheRetention: "short"
|
|
2122
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
2121
2123
|
}
|
|
2122
2124
|
};
|
|
2123
2125
|
modelsMutated = true;
|
|
@@ -2066,16 +2066,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
2066
2066
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
2067
2067
|
let modelsMutated = false;
|
|
2068
2068
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
2069
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
2069
2070
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
2070
|
-
|
|
2071
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
2072
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
2071
2073
|
const current = entry ?? {};
|
|
2072
2074
|
const params = current.params ?? {};
|
|
2073
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
2075
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
2074
2076
|
nextModels[key] = {
|
|
2075
2077
|
...current,
|
|
2076
2078
|
params: {
|
|
2077
2079
|
...params,
|
|
2078
|
-
cacheRetention: "short"
|
|
2080
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
2079
2081
|
}
|
|
2080
2082
|
};
|
|
2081
2083
|
modelsMutated = true;
|
|
@@ -2087,12 +2089,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
2087
2089
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
2088
2090
|
const current = nextModels[key] ?? {};
|
|
2089
2091
|
const params = current.params ?? {};
|
|
2090
|
-
if (typeof params.cacheRetention !== "string") {
|
|
2092
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
2091
2093
|
nextModels[key] = {
|
|
2092
2094
|
...current,
|
|
2093
2095
|
params: {
|
|
2094
2096
|
...params,
|
|
2095
|
-
cacheRetention: "short"
|
|
2097
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
2096
2098
|
}
|
|
2097
2099
|
};
|
|
2098
2100
|
modelsMutated = true;
|
|
@@ -1997,16 +1997,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
1997
1997
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
1998
1998
|
let modelsMutated = false;
|
|
1999
1999
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
2000
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
2000
2001
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
2001
|
-
|
|
2002
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
2003
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
2002
2004
|
const current = entry ?? {};
|
|
2003
2005
|
const params = current.params ?? {};
|
|
2004
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
2006
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
2005
2007
|
nextModels[key] = {
|
|
2006
2008
|
...current,
|
|
2007
2009
|
params: {
|
|
2008
2010
|
...params,
|
|
2009
|
-
cacheRetention: "short"
|
|
2011
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
2010
2012
|
}
|
|
2011
2013
|
};
|
|
2012
2014
|
modelsMutated = true;
|
|
@@ -2018,12 +2020,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
2018
2020
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
2019
2021
|
const current = nextModels[key] ?? {};
|
|
2020
2022
|
const params = current.params ?? {};
|
|
2021
|
-
if (typeof params.cacheRetention !== "string") {
|
|
2023
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
2022
2024
|
nextModels[key] = {
|
|
2023
2025
|
...current,
|
|
2024
2026
|
params: {
|
|
2025
2027
|
...params,
|
|
2026
|
-
cacheRetention: "short"
|
|
2028
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
2027
2029
|
}
|
|
2028
2030
|
};
|
|
2029
2031
|
modelsMutated = true;
|
|
@@ -27953,7 +27953,9 @@ function resolveModelAuthLabel(params) {
|
|
|
27953
27953
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
27954
27954
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
27955
27955
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
27956
|
-
|
|
27956
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
27957
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
27958
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
27957
27959
|
cfg: params.cfg,
|
|
27958
27960
|
store,
|
|
27959
27961
|
provider: providerKey,
|
|
@@ -52919,6 +52921,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
52919
52921
|
const patch = {
|
|
52920
52922
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
52921
52923
|
model: params.modelUsed ?? entry.model,
|
|
52924
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
52922
52925
|
contextTokens: resolvedContextTokens,
|
|
52923
52926
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
52924
52927
|
updatedAt: Date.now()
|
|
@@ -53198,6 +53201,7 @@ function createFollowupRunner(params) {
|
|
|
53198
53201
|
promptTokens,
|
|
53199
53202
|
modelUsed,
|
|
53200
53203
|
providerUsed: fallbackProvider,
|
|
53204
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53201
53205
|
contextTokensUsed,
|
|
53202
53206
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53203
53207
|
logLabel: "followup"
|
|
@@ -53662,6 +53666,7 @@ async function runReplyAgent(params) {
|
|
|
53662
53666
|
promptTokens,
|
|
53663
53667
|
modelUsed,
|
|
53664
53668
|
providerUsed,
|
|
53669
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53665
53670
|
contextTokensUsed,
|
|
53666
53671
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53667
53672
|
cliSessionId
|
|
@@ -69832,6 +69837,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
69832
69837
|
provider: providerUsed,
|
|
69833
69838
|
model: modelUsed
|
|
69834
69839
|
});
|
|
69840
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
69835
69841
|
if (isCliProvider(providerUsed, cfg)) {
|
|
69836
69842
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
69837
69843
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -97961,7 +97967,7 @@ function resolveExtraParams(params) {
|
|
|
97961
97967
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
97962
97968
|
* of the cacheRetention stream option.
|
|
97963
97969
|
*
|
|
97964
|
-
*
|
|
97970
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
97965
97971
|
*/
|
|
97966
97972
|
function resolveCacheRetention(extraParams, provider) {
|
|
97967
97973
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -97973,10 +97979,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
97973
97979
|
if (legacy === "5m") return "short";
|
|
97974
97980
|
if (legacy === "1h") return "long";
|
|
97975
97981
|
if (!isAnthropicDirect) return;
|
|
97976
|
-
return "
|
|
97982
|
+
return "long";
|
|
97977
97983
|
}
|
|
97978
97984
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
97979
|
-
|
|
97985
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
97986
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
97987
|
+
extraParams ??= {};
|
|
97980
97988
|
const streamParams = {};
|
|
97981
97989
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
97982
97990
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -104750,7 +104758,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
104750
104758
|
usage,
|
|
104751
104759
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
104752
104760
|
promptTokens,
|
|
104753
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
104761
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
104762
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
104754
104763
|
};
|
|
104755
104764
|
const payloads = buildEmbeddedRunPayloads({
|
|
104756
104765
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -27949,7 +27949,9 @@ function resolveModelAuthLabel(params) {
|
|
|
27949
27949
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
27950
27950
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
27951
27951
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
27952
|
-
|
|
27952
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
27953
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
27954
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
27953
27955
|
cfg: params.cfg,
|
|
27954
27956
|
store,
|
|
27955
27957
|
provider: providerKey,
|
|
@@ -52915,6 +52917,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
52915
52917
|
const patch = {
|
|
52916
52918
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
52917
52919
|
model: params.modelUsed ?? entry.model,
|
|
52920
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
52918
52921
|
contextTokens: resolvedContextTokens,
|
|
52919
52922
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
52920
52923
|
updatedAt: Date.now()
|
|
@@ -53194,6 +53197,7 @@ function createFollowupRunner(params) {
|
|
|
53194
53197
|
promptTokens,
|
|
53195
53198
|
modelUsed,
|
|
53196
53199
|
providerUsed: fallbackProvider,
|
|
53200
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53197
53201
|
contextTokensUsed,
|
|
53198
53202
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53199
53203
|
logLabel: "followup"
|
|
@@ -53658,6 +53662,7 @@ async function runReplyAgent(params) {
|
|
|
53658
53662
|
promptTokens,
|
|
53659
53663
|
modelUsed,
|
|
53660
53664
|
providerUsed,
|
|
53665
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53661
53666
|
contextTokensUsed,
|
|
53662
53667
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53663
53668
|
cliSessionId
|
|
@@ -69828,6 +69833,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
69828
69833
|
provider: providerUsed,
|
|
69829
69834
|
model: modelUsed
|
|
69830
69835
|
});
|
|
69836
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
69831
69837
|
if (isCliProvider(providerUsed, cfg)) {
|
|
69832
69838
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
69833
69839
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -97951,7 +97957,7 @@ function resolveExtraParams(params) {
|
|
|
97951
97957
|
* OpenRouter uses openai-completions API with hardcoded cache_control instead
|
|
97952
97958
|
* of the cacheRetention stream option.
|
|
97953
97959
|
*
|
|
97954
|
-
*
|
|
97960
|
+
* JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: defaults to "long" for direct Anthropic (both auth modes).
|
|
97955
97961
|
*/
|
|
97956
97962
|
function resolveCacheRetention(extraParams, provider) {
|
|
97957
97963
|
const isAnthropicDirect = provider === "anthropic";
|
|
@@ -97963,10 +97969,12 @@ function resolveCacheRetention(extraParams, provider) {
|
|
|
97963
97969
|
if (legacy === "5m") return "short";
|
|
97964
97970
|
if (legacy === "1h") return "long";
|
|
97965
97971
|
if (!isAnthropicDirect) return;
|
|
97966
|
-
return "
|
|
97972
|
+
return "long";
|
|
97967
97973
|
}
|
|
97968
97974
|
function createStreamFnWithExtraParams(baseStreamFn, extraParams, provider) {
|
|
97969
|
-
|
|
97975
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: apply the Anthropic default even with no model params.
|
|
97976
|
+
if ((!extraParams || Object.keys(extraParams).length === 0) && provider !== "anthropic") return;
|
|
97977
|
+
extraParams ??= {};
|
|
97970
97978
|
const streamParams = {};
|
|
97971
97979
|
if (typeof extraParams.temperature === "number") streamParams.temperature = extraParams.temperature;
|
|
97972
97980
|
if (typeof extraParams.maxTokens === "number") streamParams.maxTokens = extraParams.maxTokens;
|
|
@@ -104718,7 +104726,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
104718
104726
|
usage,
|
|
104719
104727
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
104720
104728
|
promptTokens,
|
|
104721
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
104729
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
104730
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
104722
104731
|
};
|
|
104723
104732
|
const payloads = buildEmbeddedRunPayloads({
|
|
104724
104733
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -7468,16 +7468,18 @@ function applyContextPruningDefaults(cfg) {
|
|
|
7468
7468
|
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
7469
7469
|
let modelsMutated = false;
|
|
7470
7470
|
const isAnthropicCacheRetentionTarget = (parsed) => Boolean(parsed && (parsed.provider === "anthropic" || parsed.provider === "amazon-bedrock" && parsed.model.toLowerCase().includes("anthropic.claude")));
|
|
7471
|
+
// JOHNNESS_PATCH_ANTHROPIC_CACHE_LONG_90: direct Anthropic uses 1h; Bedrock keeps its existing default.
|
|
7471
7472
|
for (const [key, entry] of Object.entries(nextModels)) {
|
|
7472
|
-
|
|
7473
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
7474
|
+
if (!isAnthropicCacheRetentionTarget(parsed)) continue;
|
|
7473
7475
|
const current = entry ?? {};
|
|
7474
7476
|
const params = current.params ?? {};
|
|
7475
|
-
if (typeof params.cacheRetention === "string") continue;
|
|
7477
|
+
if (typeof params.cacheRetention === "string" || parsed.provider === "anthropic" && params.cacheControlTtl !== void 0) continue;
|
|
7476
7478
|
nextModels[key] = {
|
|
7477
7479
|
...current,
|
|
7478
7480
|
params: {
|
|
7479
7481
|
...params,
|
|
7480
|
-
cacheRetention: "short"
|
|
7482
|
+
cacheRetention: parsed.provider === "anthropic" ? "long" : "short"
|
|
7481
7483
|
}
|
|
7482
7484
|
};
|
|
7483
7485
|
modelsMutated = true;
|
|
@@ -7489,12 +7491,12 @@ function applyContextPruningDefaults(cfg) {
|
|
|
7489
7491
|
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
7490
7492
|
const current = nextModels[key] ?? {};
|
|
7491
7493
|
const params = current.params ?? {};
|
|
7492
|
-
if (typeof params.cacheRetention !== "string") {
|
|
7494
|
+
if (typeof params.cacheRetention !== "string" && !(parsedPrimary.provider === "anthropic" && params.cacheControlTtl !== void 0)) {
|
|
7493
7495
|
nextModels[key] = {
|
|
7494
7496
|
...current,
|
|
7495
7497
|
params: {
|
|
7496
7498
|
...params,
|
|
7497
|
-
cacheRetention: "short"
|
|
7499
|
+
cacheRetention: parsedPrimary.provider === "anthropic" ? "long" : "short"
|
|
7498
7500
|
}
|
|
7499
7501
|
};
|
|
7500
7502
|
modelsMutated = true;
|