fix: restore 1h cache ttl option
This commit is contained in:
@@ -1414,7 +1414,7 @@ Each `agents.defaults.models` entry can include:
|
|||||||
- `alias` (optional model shortcut, e.g. `/opus`).
|
- `alias` (optional model shortcut, e.g. `/opus`).
|
||||||
- `params` (optional provider-specific API params passed through to the model request).
|
- `params` (optional provider-specific API params passed through to the model request).
|
||||||
|
|
||||||
`params` is also applied to streaming runs (embedded agent + compaction). Supported keys today: `temperature`, `maxTokens`, `cacheControlTtl` (`"5m"`, Anthropic API + OpenRouter Anthropic models only; ignored for Anthropic OAuth/Claude Code tokens). These merge with call-time options; caller-supplied values win. `temperature` is an advanced knob—leave unset unless you know the model’s defaults and need a change. Clawdbot includes the `extended-cache-ttl-2025-04-11` beta flag for Anthropic API; keep it if you override provider headers.
|
`params` is also applied to streaming runs (embedded agent + compaction). Supported keys today: `temperature`, `maxTokens`, `cacheControlTtl` (`"5m"` or `"1h"`, Anthropic API + OpenRouter Anthropic models only; ignored for Anthropic OAuth/Claude Code tokens). These merge with call-time options; caller-supplied values win. `temperature` is an advanced knob—leave unset unless you know the model’s defaults and need a change. Clawdbot includes the `extended-cache-ttl-2025-04-11` beta flag for Anthropic API; keep it if you override provider headers.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ To set the TTL per model, use `cacheControlTtl` in the model `params`:
|
|||||||
defaults: {
|
defaults: {
|
||||||
models: {
|
models: {
|
||||||
"anthropic/claude-opus-4-5": {
|
"anthropic/claude-opus-4-5": {
|
||||||
params: { cacheControlTtl: "5m" }
|
params: { cacheControlTtl: "5m" } // or "1h"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export function resolveExtraParams(params: {
|
|||||||
return modelConfig?.params ? { ...modelConfig.params } : undefined;
|
return modelConfig?.params ? { ...modelConfig.params } : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
type CacheControlTtl = "5m";
|
type CacheControlTtl = "5m" | "1h";
|
||||||
|
|
||||||
function resolveCacheControlTtl(
|
function resolveCacheControlTtl(
|
||||||
extraParams: Record<string, unknown> | undefined,
|
extraParams: Record<string, unknown> | undefined,
|
||||||
@@ -29,7 +29,7 @@ function resolveCacheControlTtl(
|
|||||||
modelId: string,
|
modelId: string,
|
||||||
): CacheControlTtl | undefined {
|
): CacheControlTtl | undefined {
|
||||||
const raw = extraParams?.cacheControlTtl;
|
const raw = extraParams?.cacheControlTtl;
|
||||||
if (raw !== "5m") return undefined;
|
if (raw !== "5m" && raw !== "1h") return undefined;
|
||||||
if (provider === "anthropic") return raw;
|
if (provider === "anthropic") return raw;
|
||||||
if (provider === "openrouter" && modelId.startsWith("anthropic/")) return raw;
|
if (provider === "openrouter" && modelId.startsWith("anthropic/")) return raw;
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user