@gajae-code/ai 0.5.1 → 0.5.2
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 +6 -0
- package/dist/types/utils.d.ts +8 -2
- package/package.json +2 -2
- package/src/providers/anthropic.ts +10 -1
- package/src/utils.ts +13 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.5.2] - 2026-06-15
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Changed the Anthropic provider's default prompt-cache retention to `long` (`ttl: "1h"`) when a request and model omit `cacheRetention`. The previous default (~5m) was too fragile for long-running Codex/Gajae-Code subagent workflows, where the cached prefix was frequently evicted between turns. The 1h `ttl` marker is only emitted on the canonical Anthropic API (`api.anthropic.com`) for models advertising `supportsLongCacheRetention`; proxies, gateways, and models without that capability still fall back to the default ephemeral breakpoint (Anthropic services it at ~5m). Explicit request/model `cacheRetention` and the `GJC_CACHE_RETENTION`/`PI_CACHE_RETENTION` env overrides continue to win, and `resolveCacheRetention` now accepts a `fallback` argument (defaulting to `"short"`) so non-Anthropic providers are unaffected.
|
|
10
|
+
|
|
5
11
|
## [0.5.1] - 2026-06-14
|
|
6
12
|
|
|
7
13
|
### Fixed
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -22,7 +22,13 @@ export declare function getOpenAIResponsesHistoryPayload(providerPayload: Provid
|
|
|
22
22
|
export declare function getOpenAIResponsesHistoryItems(providerPayload: ProviderPayload | undefined, currentProvider: string, fallbackProvider?: string): Array<Record<string, unknown>> | undefined;
|
|
23
23
|
/**
|
|
24
24
|
* Resolve cache retention preference.
|
|
25
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* Resolution order: explicit request value → `GJC_CACHE_RETENTION` →
|
|
27
|
+
* legacy `PI_CACHE_RETENTION` → `fallback`. Both env vars act as explicit
|
|
28
|
+
* opt-in (`"long"`) or opt-out (any other value) so a provider-specific
|
|
29
|
+
* `fallback` only applies when nothing else is configured. `fallback`
|
|
30
|
+
* defaults to `"short"` to preserve the historical behaviour for callers
|
|
31
|
+
* that don't pass one.
|
|
26
32
|
*/
|
|
27
|
-
export declare function resolveCacheRetention(cacheRetention?: CacheRetention): CacheRetention;
|
|
33
|
+
export declare function resolveCacheRetention(cacheRetention?: CacheRetention, fallback?: CacheRetention): CacheRetention;
|
|
28
34
|
export declare function isAnthropicOAuthToken(key: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/ai",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
6
6
|
"homepage": "https://gaebal-gajae.dev",
|
|
7
7
|
"author": "Yeachan-Heo",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@anthropic-ai/sdk": "^0.94.0",
|
|
45
45
|
"@bufbuild/protobuf": "^2.12.0",
|
|
46
|
-
"@gajae-code/utils": "0.5.
|
|
46
|
+
"@gajae-code/utils": "0.5.2",
|
|
47
47
|
"openai": "^6.36.0",
|
|
48
48
|
"partial-json": "^0.1.7",
|
|
49
49
|
"zod": "4.4.3"
|
|
@@ -353,10 +353,19 @@ function getCacheControl(
|
|
|
353
353
|
baseUrl: string,
|
|
354
354
|
cacheRetention?: CacheRetention,
|
|
355
355
|
): { retention: CacheRetention; cacheControl?: AnthropicCacheControl } {
|
|
356
|
-
|
|
356
|
+
// Default Anthropic prompt caching to long (1h) retention. The provider
|
|
357
|
+
// default of ~5m is too fragile for long-running Codex/Gajae-Code subagent
|
|
358
|
+
// workflows, where the prefix is frequently evicted between turns. Explicit
|
|
359
|
+
// request/model `cacheRetention` and the GJC_CACHE_RETENTION /
|
|
360
|
+
// PI_CACHE_RETENTION env overrides still win.
|
|
361
|
+
const retention = resolveCacheRetention(cacheRetention, "long");
|
|
357
362
|
if (retention === "none") {
|
|
358
363
|
return { retention };
|
|
359
364
|
}
|
|
365
|
+
// `ttl: "1h"` is only honoured on the canonical Anthropic API for models
|
|
366
|
+
// that advertise long-cache support. Everywhere else (proxies, gateways,
|
|
367
|
+
// models without the capability) we fall back to the default ephemeral
|
|
368
|
+
// breakpoint, which Anthropic services at the standard ~5m TTL.
|
|
360
369
|
const ttl =
|
|
361
370
|
retention === "long" && isAnthropicApiBaseUrl(baseUrl) && getAnthropicCompat(model).supportsLongCacheRetention
|
|
362
371
|
? "1h"
|
package/src/utils.ts
CHANGED
|
@@ -153,14 +153,24 @@ export function getOpenAIResponsesHistoryItems(
|
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* Resolve cache retention preference.
|
|
156
|
-
*
|
|
156
|
+
*
|
|
157
|
+
* Resolution order: explicit request value → `GJC_CACHE_RETENTION` →
|
|
158
|
+
* legacy `PI_CACHE_RETENTION` → `fallback`. Both env vars act as explicit
|
|
159
|
+
* opt-in (`"long"`) or opt-out (any other value) so a provider-specific
|
|
160
|
+
* `fallback` only applies when nothing else is configured. `fallback`
|
|
161
|
+
* defaults to `"short"` to preserve the historical behaviour for callers
|
|
162
|
+
* that don't pass one.
|
|
157
163
|
*/
|
|
158
|
-
export function resolveCacheRetention(
|
|
164
|
+
export function resolveCacheRetention(
|
|
165
|
+
cacheRetention?: CacheRetention,
|
|
166
|
+
fallback: CacheRetention = "short",
|
|
167
|
+
): CacheRetention {
|
|
159
168
|
if (cacheRetention) return cacheRetention;
|
|
160
169
|
if ($env.GJC_CACHE_RETENTION === "long") return "long";
|
|
161
170
|
if ($env.GJC_CACHE_RETENTION !== undefined) return "short";
|
|
162
171
|
if ($env.PI_CACHE_RETENTION === "long") return "long";
|
|
163
|
-
return "short";
|
|
172
|
+
if ($env.PI_CACHE_RETENTION !== undefined) return "short";
|
|
173
|
+
return fallback;
|
|
164
174
|
}
|
|
165
175
|
|
|
166
176
|
export function isAnthropicOAuthToken(key: string): boolean {
|