Python
feat(sdk): enable configurable Anthropic prompt caching
Rohit P6b90a32245f2
diff --git a/docs/harness/guides/providers.md b/docs/harness/guides/providers.mdindex 7438cd07..051d2a79 100644--- a/docs/harness/guides/providers.md+++ b/docs/harness/guides/providers.md@@ -66,3 +66,38 @@ may never deliver its final accounting frame. Token counts alone also do notestablish a dollar cost; apply the pricing for the chosen provider and model.The [OpenAI streaming contract](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)describes the optional final usage chunk.++## Anthropic prompt caching++Anthropic Messages requests enable automatic prompt caching by default using+`cache_control: { type: "ephemeral" }`. The provider moves the cache breakpoint+with the growing conversation, covering the reusable tool definitions, system+instructions and history. The default lifetime is five minutes. A request below+the provider's minimum cacheable length can still report zero cache reads.++Disable it for a proxy that rejects this field, or when your application does+not want caching:++```typescript+await harness.setModelProvider({+ name: "Anthropic", api: "anthropic",+ credentials: { apiKeyEnv: "ANTHROPIC_API_KEY", storage: "memory" },+ promptCaching: false,+});+```++```rust,ignore+harness.set_model_provider(+ ModelProvider::anthropic("Anthropic")+ .credentials(Credentials::from_env("ANTHROPIC_API_KEY").memory_only())+ .prompt_caching(false),+).await?;+```++The choice persists across credential rotation and restart. Omission preserves+an existing choice; `true` re-enables caching. The option is valid only for+Anthropic Messages. There is no silent fallback or automatic request replay.+`model_usage` reports cache reads and writes separately; total input tokens+include both. Actual hit rates and cost depend on model, prefix stability,+minimum prompt size and provider pricing. See+[Anthropic's prompt caching guide](https://platform.claude.com/docs/en/build-with-claude/prompt-caching).diff --git a/harness/harness-sdk/src/providers.rs b/harness/harness-sdk/src/providers.rsindex 1fe0f3bc..03e78f7d 100644--- a/harness/harness-sdk/src/providers.rs+++ b/harness/harness-sdk/src/providers.rs@@ -49,6 +49,7 @@ pub struct ModelProvider {api: ModelApi,base_url: Option<String>,stream_usage: Option<bool>,+ prompt_caching: Option<bool>,credentials: Option<Credentials>,pub(crate) access_auth: bool,pub(crate) refresh: Option<openworker_runtime::provider_auth::Refresh>,@@ -69,6 +70,7 @@ impl ModelProvider {api,base_url: None,stream_usage: None,+ prompt_caching: None,credentials: None,access_auth: false,refresh: None,@@ -85,6 +87,12 @@ impl ModelProvider {self.stream_usage = Some(enabled);self}+ /// Anthropic automatic prompt caching (default true). Set false for a+ /// proxy that rejects cache_control or when caching is not desired.+ pub fn prompt_caching(mut self, enabled: bool) -> Self {+ self.prompt_caching = Some(enabled);+ self+ }pub fn credentials(mut self, value: Credentials) -> Self {self.credentials = Some(value);self@@ -115,6 +123,11 @@ impl ModelProvider {&self.name}pub(crate) fn wire(self) -> Result<Value> {+ if self.prompt_caching.is_some() && self.api != ModelApi::Anthropic {+ return Err(Error::InvalidInput(+ "prompt_caching is only supported for Anthropic Messages".into(),+ ));+ }if self.stream_usage.is_some() && self.api != ModelApi::ChatCompletions {return Err(Error::InvalidInput("stream_usage is only supported for Chat Completions".into(),@@ -129,6 +142,9 @@ impl ModelProvider {if let Some(enabled) = self.stream_usage {wire["stream_usage"] = json!(enabled);}+ if let Some(enabled) = self.prompt_caching {+ wire["prompt_caching"] = json!(enabled);+ }if self.access_auth {wire["access_token_auth"] = json!(true);}@@ -143,6 +159,30 @@ pub type Model = crate::ModelChoice;mod tests {use super::*;+ #[test]+ fn anthropic_prompt_caching_override_is_explicit_and_api_scoped() {+ assert!(ModelProvider::anthropic("Claude")+ .wire()+ .unwrap()+ .get("prompt_caching")+ .is_none());+ assert_eq!(+ ModelProvider::anthropic("Claude")+ .prompt_caching(false)+ .wire()+ .unwrap()["prompt_caching"],+ false+ );+ assert!(ModelProvider::chat_completions("Local")+ .prompt_caching(false)+ .wire()+ .is_err());+ assert!(ModelProvider::responses("OpenAI")+ .prompt_caching(true)+ .wire()+ .is_err());+ }+#[test]fn chat_stream_usage_override_is_explicit_and_api_scoped() {let default = ModelProvider::chat_completions("Local").wire().unwrap();diff --git a/harness/runtime/src/anthropic.rs b/harness/runtime/src/anthropic.rsindex fdcbc30a..2205745c 100644--- a/harness/runtime/src/anthropic.rs+++ b/harness/runtime/src/anthropic.rs@@ -139,7 +139,10 @@ pub fn body(if t["type"] != "function" || !t["parameters"].is_object() { return Err(config()); }Ok(json!({"name":t["name"].as_str().ok_or_else(config)?,"description":t["description"].as_str().unwrap_or(""),"input_schema":t["parameters"]}))}).collect::<Result<Vec<_>,Error>>()?;- let mut body = json!({"model":model,"system":instructions,"messages":messages,"max_tokens":max_tokens,"stream":true});+ // Automatic caching moves the breakpoint with the growing conversation.+ // The provider decides eligibility/minimum prefix length; a request does+ // not imply a cache hit. Applications can explicitly opt out per provider.+ let mut body = json!({"model":model,"system":instructions,"messages":messages,"max_tokens":max_tokens,"stream":true,"cache_control":{"type":"ephemeral"}});if !definitions.is_empty() {body["tools"] = json!(definitions);body["tool_choice"] = json!({"type":"auto","disable_parallel_tool_use":true});diff --git a/harness/runtime/src/connections.rs b/harness/runtime/src/connections.rsindex 14beb057..b8e39034 100644--- a/harness/runtime/src/connections.rs+++ b/harness/runtime/src/connections.rs@@ -72,6 +72,8 @@ struct Set {base_url: Option<String>,#[serde(default)]stream_usage: Option<bool>,+ #[serde(default)]+ prompt_caching: Option<bool>,}impl Manager {/// Trusted server bootstrap only; not exposed by the model or stdio protocol.@@ -182,6 +184,17 @@ impl Manager {"ALTER TABLE endpoints ADD COLUMN stream_usage INTEGER NOT NULL DEFAULT 1 CHECK(stream_usage IN (0,1))",)?;}+ let has_prompt_caching = db+ .prepare("PRAGMA table_info(endpoints)")?+ .query_map([], |r| r.get::<_, String>(1))?+ .collect::<std::result::Result<Vec<_>, _>>()?+ .iter()+ .any(|name| name == "prompt_caching");+ if !has_prompt_caching {+ db.execute_batch(+ "ALTER TABLE endpoints ADD COLUMN prompt_caching INTEGER NOT NULL DEFAULT 1 CHECK(prompt_caching IN (0,1))",+ )?;+ }Ok(Self {scope: root.canonicalize()?.to_string_lossy().into(),state: Mutex::new(State {@@ -210,20 +223,21 @@ impl Manager {for row in rows {let (id, label, persistence, stored, provider) = row?;use rusqlite::OptionalExtension;- let endpoint: Option<(String, String, bool)> = state+ let endpoint: Option<(String, String, bool, bool)> = state.db.query_row(- "SELECT api,base_url,stream_usage FROM endpoints WHERE id=?1",+ "SELECT api,base_url,stream_usage,prompt_caching FROM endpoints WHERE id=?1",[&id],- |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)),+ |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?, r.get(3)?)),).optional()?;- let (api, base_url, stream_usage) = endpoint- .map(|(a, b, usage)| {+ let (api, base_url, stream_usage, prompt_caching) = endpoint+ .map(|(a, b, usage, caching)| {(serde_json::from_str::<Value>(&a).unwrap_or(Value::Null),b,usage,+ caching,)}).unwrap_or_else(|| {@@ -232,12 +246,15 @@ impl Manager {} else {crate::model_api::Api::Responses};- (json!(api), api.default_url().into(), true)+ (json!(api), api.default_url().into(), true, true)});connections.push(json!({"id":id,"name":id,"label":label,"provider":provider,"api":api,"base_url":base_url,"persistence":persistence,"configured":persistence=="none"||stored||state.memory.contains_key(&id)||state.tokens.get(&id).is_some_and(|t|t.ready())}));if api == "chat-completions" {connections.last_mut().unwrap()["stream_usage"] = json!(stream_usage);}+ if api == "anthropic" {+ connections.last_mut().unwrap()["prompt_caching"] = json!(prompt_caching);+ }}Ok(json!({"connections":connections,"secure_storage_available":cfg!(any(windows,target_os="macos"))}),@@ -261,6 +278,9 @@ impl Manager {if input.stream_usage.is_some() && api != crate::model_api::Api::ChatCompletions {bail!("stream_usage is only supported for Chat Completions");}+ if input.prompt_caching.is_some() && api != crate::model_api::Api::Anthropic {+ bail!("prompt_caching is only supported for Anthropic Messages");+ }let base_url =crate::model_api::base_url(input.base_url.as_deref().unwrap_or(api.default_url()))?;let api_json = serde_json::to_string(&api)?;@@ -352,8 +372,8 @@ impl Manager {ON CONFLICT(id) DO UPDATE SET label=excluded.label,persistence=excluded.persistence,secret=excluded.secret",params![input.id,input.label,crate::id("connection"),input.persistence,encrypted,input.provider.name()])?;transaction.execute(- "INSERT INTO endpoints(id,api,base_url,stream_usage) VALUES(?1,?2,?3,COALESCE(?4,1)) ON CONFLICT(id) DO UPDATE SET stream_usage=COALESCE(?4,endpoints.stream_usage)",- params![input.id, api_json, base_url, input.stream_usage],+ "INSERT INTO endpoints(id,api,base_url,stream_usage,prompt_caching) VALUES(?1,?2,?3,COALESCE(?4,1),COALESCE(?5,1)) ON CONFLICT(id) DO UPDATE SET stream_usage=COALESCE(?4,endpoints.stream_usage),prompt_caching=COALESCE(?5,endpoints.prompt_caching)",+ params![input.id, api_json, base_url, input.stream_usage, input.prompt_caching],)?;transaction.commit()?;#[cfg(target_os = "macos")]@@ -607,6 +627,14 @@ impl Manager {|r| r.get(0),).context("Selected model provider is missing or its identity changed")}+ /// Anthropic automatic prompt caching is on unless explicitly disabled.+ pub fn prompt_caching(&self, selected: &Selection) -> Result<bool> {+ self.state.lock().unwrap().db.query_row(+ "SELECT COALESCE(e.prompt_caching,1) FROM connections c LEFT JOIN endpoints e ON c.id=e.id WHERE c.id=?1 AND c.identity=?2",+ params![selected.connection, selected.identity],+ |r| r.get(0),+ ).context("Selected model provider is missing or its identity changed")+ }/// Harness-owned provider registration; never journal this secret-bearing request.pub fn set_provider(&self, value: Value) -> Result<Value> {#[derive(Deserialize)]@@ -619,6 +647,8 @@ impl Manager {#[serde(default)]stream_usage: Option<bool>,#[serde(default)]+ prompt_caching: Option<bool>,+ #[serde(default)]access_token_auth: bool,}#[derive(Deserialize)]@@ -633,6 +663,9 @@ impl Manager {if input.stream_usage.is_some() && input.api != crate::model_api::Api::ChatCompletions {bail!("stream_usage is only supported for Chat Completions");}+ if input.prompt_caching.is_some() && input.api != crate::model_api::Api::Anthropic {+ bail!("prompt_caching is only supported for Anthropic Messages");+ }anyhow::ensure!(!input.access_token_auth|| (input.credentials.is_none()@@ -691,6 +724,12 @@ impl Manager {params![input.name, enabled],)?;}+ if let Some(enabled) = input.prompt_caching {+ self.state.lock().unwrap().db.execute(+ "INSERT INTO endpoints(id,api,base_url,prompt_caching) VALUES(?1,?2,?3,?4) ON CONFLICT(id) DO UPDATE SET prompt_caching=excluded.prompt_caching",+ params![input.name, serde_json::to_string(&input.api)?, base_url, enabled],+ )?;+ }return Ok(json!({"saved":true,"credentials_unchanged":true}));}}@@ -712,7 +751,7 @@ impl Manager {.into(),),};- self.set(json!({"id":input.name,"label":input.name,"provider":input.api.kind(),"api":input.api,"base_url":base_url,"stream_usage":input.stream_usage,"api_key":key,"persistence":storage}))+ self.set(json!({"id":input.name,"label":input.name,"provider":input.api.kind(),"api":input.api,"base_url":base_url,"stream_usage":input.stream_usage,"prompt_caching":input.prompt_caching,"api_key":key,"persistence":storage}))}}#[cfg(not(any(windows, target_os = "macos")))]diff --git a/harness/runtime/src/model.rs b/harness/runtime/src/model.rsindex 743cfd56..a1b9c27d 100644--- a/harness/runtime/src/model.rs+++ b/harness/runtime/src/model.rs@@ -387,7 +387,7 @@ impl Model {return Ok(());}if api == crate::model_api::Api::Anthropic {- let body = crate::anthropic::body(+ let mut body = crate::anthropic::body(&self.name,instructions,history,@@ -395,6 +395,11 @@ impl Model {max_tokens,format.as_ref(),)?;+ if let Some((manager, selection)) = &self.connection {+ if !manager.prompt_caching(selection)? {+ body.as_object_mut().unwrap().remove("cache_control");+ }+ }crate::anthropic::request(&client, &endpoint, key, body, tx).await?;return Ok(());}diff --git a/harness/runtime/tests/anthropic.rs b/harness/runtime/tests/anthropic.rsindex dd0573bd..fdadf6a0 100644--- a/harness/runtime/tests/anthropic.rs+++ b/harness/runtime/tests/anthropic.rs@@ -41,6 +41,7 @@ fn completed_tool_usage_and_history_roundtrip() {history.push(json!({"type":"function_call_output","call_id":"tool_1","output":"report contents"}));let request = anthropic::body("claude-test", "Instructions", &history, &[json!({"type":"function","name":"read_file","description":"read","parameters":{"type":"object"}})], 8192, None).unwrap();+ assert_eq!(request["cache_control"], json!({"type":"ephemeral"}));assert_eq!(request["messages"][1]["content"][0]["input"]["path"],"report.txt"diff --git a/harness/runtime/tests/connections.rs b/harness/runtime/tests/connections.rsindex 6ed15ba3..482a2e40 100644--- a/harness/runtime/tests/connections.rs+++ b/harness/runtime/tests/connections.rs@@ -312,6 +312,60 @@ fn chat_stream_usage_migrates_existing_endpoint_rows() {.unwrap());}+#[test]+fn anthropic_prompt_caching_is_durable_and_preserves_provider_identity() {+ let root = tempfile::tempdir().unwrap();+ let m = Manager::open(root.path()).unwrap();+ let config = json!({"name":"Claude","api":"anthropic","credentials":{"api_key":"fixture-key-one","storage":"memory"}});+ m.set_provider(config.clone()).unwrap();+ let selected = m.resolve(&Choice::new("Claude", "fixture")).unwrap();+ assert!(m.prompt_caching(&selected).unwrap());+ let mut disabled = config.clone();+ disabled["prompt_caching"] = json!(false);+ m.set_provider(disabled).unwrap();+ let mut rotated = config;+ rotated["credentials"]["api_key"] = json!("fixture-key-two");+ m.set_provider(rotated).unwrap();+ assert!(!m.prompt_caching(&selected).unwrap());+ assert_eq!(&**m.key(&selected).unwrap(), "fixture-key-two");+ drop(m);+ let m = Manager::open(root.path()).unwrap();+ m.set_provider(json!({"name":"Claude","api":"anthropic"}))+ .unwrap();+ assert!(!m.prompt_caching(&selected).unwrap());+ assert_eq!(m.list().unwrap()["connections"][0]["prompt_caching"], false);+ m.set_provider(json!({"name":"Claude","api":"anthropic","prompt_caching":true}))+ .unwrap();+ assert!(m.prompt_caching(&selected).unwrap());+ for api in ["responses", "chat-completions"] {+ assert!(m+ .set_provider(json!({"name":"Wrong","api":api,"prompt_caching":false}))+ .is_err());+ }+ m.remove("Claude").unwrap();+ assert!(m.prompt_caching(&selected).is_err());+}++#[test]+fn legacy_anthropic_connections_can_opt_out_without_replacing_credentials() {+ let root = tempfile::tempdir().unwrap();+ let db = rusqlite::Connection::open(root.path().join("model-connections.sqlite")).unwrap();+ db.execute_batch(+ "CREATE TABLE connections(id TEXT PRIMARY KEY,label TEXT NOT NULL,identity TEXT NOT NULL,persistence TEXT NOT NULL,secret BLOB,provider TEXT NOT NULL);+ CREATE TABLE endpoints(id TEXT PRIMARY KEY,api TEXT NOT NULL,base_url TEXT NOT NULL);+ INSERT INTO connections VALUES('Claude','Claude','legacy-identity','none',NULL,'anthropic');",+ ).unwrap();+ drop(db);+ let m = Manager::open(root.path()).unwrap();+ let selected = m.resolve(&Choice::new("Claude", "fixture")).unwrap();+ assert!(m.prompt_caching(&selected).unwrap());+ m.set_provider(json!({"name":"Claude","api":"anthropic","prompt_caching":false}))+ .unwrap();+ assert!(!m.prompt_caching(&selected).unwrap());+ assert!(m.key(&selected).unwrap().is_empty());+ assert_eq!(selected.identity, "legacy-identity");+}+#[test]fn stream_usage_rejects_other_apis_and_supports_access_token_providers() {let root = tempfile::tempdir().unwrap();diff --git a/harness/typescript-sdk/package.json b/harness/typescript-sdk/package.jsonindex 6985da64..8a384bb9 100644--- a/harness/typescript-sdk/package.json+++ b/harness/typescript-sdk/package.json@@ -30,6 +30,7 @@"test:tool-free": "npm run build && node --test --test-concurrency=1 test/tool-free.test.mjs","test:openrouter-streaming": "npm run build && node --test test/openrouter-streaming.test.mjs","test:chat-usage": "npm run build && node --test --test-concurrency=1 test/chat-usage.test.mjs",+ "test:anthropic-caching": "npm run build && node --test --test-concurrency=1 test/anthropic-caching.test.mjs","test:provider-auth": "npm run build && node --test test/provider-auth.test.mjs","prepack": "npm run build","test:service": "npm run build && node --test test/service.test.mjs",diff --git a/harness/typescript-sdk/src/index.ts b/harness/typescript-sdk/src/index.tsindex 4cd2d1a7..45d884e2 100644--- a/harness/typescript-sdk/src/index.ts+++ b/harness/typescript-sdk/src/index.ts@@ -392,6 +392,7 @@ export class Harness {api: provider.api,base_url: provider.baseUrl,stream_usage: provider.streamUsage,+ prompt_caching: provider.promptCaching,access_token_auth: provider.auth ? true : undefined,credentials: credentials? { api_key: apiKey, storage: credentials.storage ?? "secure" }diff --git a/harness/typescript-sdk/src/types.ts b/harness/typescript-sdk/src/types.tsindex 54667bbd..e20e733b 100644--- a/harness/typescript-sdk/src/types.ts+++ b/harness/typescript-sdk/src/types.ts@@ -47,6 +47,8 @@ export interface ModelProvider {* stream_options for servers that do not support it. Omit to preserve an* existing provider setting. Missing provider usage remains unknown. */streamUsage?: boolean;+ /** Anthropic automatic prompt caching, enabled by default. False omits cache_control. */+ promptCaching?: boolean;/** Memory-only bearer access tokens; mutually exclusive with credentials. */auth?: ProviderAuth;credentials?: (diff --git a/harness/typescript-sdk/test/anthropic-caching.test.mjs b/harness/typescript-sdk/test/anthropic-caching.test.mjsnew file mode 100644index 00000000..ddf2b3b3--- /dev/null+++ b/harness/typescript-sdk/test/anthropic-caching.test.mjs@@ -0,0 +1,81 @@+// Request-sensitive synthetic cache accounting, not a claim of a live cache hit.+import test from "node:test";+import assert from "node:assert/strict";+import { createServer } from "node:http";+import { mkdtemp, rm } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { Harness } from "../dist/index.js";++const options = { skip: !process.env.OW_TS_TEST_HOST, timeout: 60000 };+for (const enabled of [true, false]) {+ test(`Anthropic automatic caching ${enabled ? "default" : "opt-out"}`, options, async (t) => {+ const root = await mkdtemp(join(tmpdir(), "ow-anthropic-caching-"));+ const requests = [];+ const server = createServer(async (req, res) => {+ let raw = "";+ for await (const chunk of req) raw += chunk;+ const input = JSON.parse(raw);+ requests.push(input);+ if (!enabled && input.cache_control !== undefined) {+ res.writeHead(400); res.end('{"error":{"type":"invalid_request_error","message":"cache_control unsupported"}}'); return;+ }+ res.writeHead(200, { "Content-Type": "text/event-stream" });+ const write = (event) => res.write(`data: ${JSON.stringify(event)}\n\n`);+ const tool = requests.length === 1;+ const cache = input.cache_control?.type === "ephemeral";+ write({ type: "message_start", message: { role: "assistant", content: [], usage: {+ input_tokens: cache ? 10 : 90,+ cache_read_input_tokens: cache && !tool ? 80 : 0,+ cache_creation_input_tokens: cache && tool ? 80 : 0,+ output_tokens: 0,+ } } });+ write({ type: "content_block_start", index: 0, content_block: tool+ ? { type: "tool_use", id: "cache-call", name: "app__check", input: {} }+ : { type: "text", text: "" } });+ write({ type: "content_block_delta", index: 0, delta: tool+ ? { type: "input_json_delta", partial_json: "{}" }+ : { type: "text_delta", text: "Checked." } });+ write({ type: "content_block_stop", index: 0 });+ write({ type: "message_delta", delta: { stop_reason: tool ? "tool_use" : "end_turn" }, usage: { output_tokens: 5 } });+ write({ type: "message_stop" });+ res.end();+ });+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));+ let harness;+ t.after(async () => {+ await harness?.shutdown(); server.closeAllConnections();+ await new Promise((resolve) => server.close(resolve));+ await rm(root, { recursive: true, force: true });+ });+ harness = await Harness.start({ executable: process.env.OW_TS_TEST_HOST, stateDir: root, sandbox: "off" });+ const provider = { name: "ClaudeFixture", api: "anthropic", baseUrl: `http://127.0.0.1:${server.address().port}/v1`, credentials: { apiKey: "fixture-key-only", storage: "memory" } };+ await harness.setModelProvider({ ...provider, ...(enabled ? {} : { promptCaching: false }) });+ // A key rotation without options must not silently re-enable an opt-out.+ await harness.setModelProvider({ ...provider, credentials: { apiKey: "fixture-key-rotated", storage: "memory" } });+ let effects = 0;+ await harness.registerTools({ namespace: "app", tools: { check: {+ description: "Read a synthetic value.", inputSchema: { type: "object", properties: {}, additionalProperties: false },+ execute: () => { effects++; return { checked: true }; },+ } } });+ const session = await harness.createAgent({ name: "cache-check", instructions: "Check then explain.", tools: ["app.check"], approvals: { mode: "only", tools: [] }, planning: false, memory: false, scheduling: false, defaultModel: { provider: "ClaudeFixture", name: "fixture" } }).newSession();+ const run = await session.send("Check the value.");+ const usage = [];+ for await (const item of run.events()) if (item.event.type === "model_usage") usage.push(item.event.data);+ assert.equal((await run.result()).status, "completed");+ assert.equal(effects, 1);+ assert.equal(requests.length, 2);+ for (const request of requests) {+ if (enabled) assert.deepEqual(request.cache_control, { type: "ephemeral" });+ else assert.equal(request.cache_control, undefined);+ }+ assert.equal(requests[0].system, requests[1].system);+ assert.deepEqual(requests[0].tools, requests[1].tools);+ assert.ok(requests[1].messages.some((m) => m.content.some((c) => c.type === "tool_result")));+ assert.equal(usage.length, 2);+ assert.equal(usage[0].cache_write_input_tokens, enabled ? 80 : 0);+ assert.equal(usage[1].cache_read_input_tokens, enabled ? 80 : 0);+ assert.equal(usage[0].input_tokens, 90);+ assert.equal(usage[1].input_tokens, 90);+ });+}