ctxcache 0.4.0__tar.gz → 0.4.1__tar.gz

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.
Files changed (158) hide show
  1. {ctxcache-0.4.0 → ctxcache-0.4.1}/CHANGELOG.md +7 -0
  2. {ctxcache-0.4.0 → ctxcache-0.4.1}/PKG-INFO +8 -6
  3. {ctxcache-0.4.0 → ctxcache-0.4.1}/README.md +7 -5
  4. ctxcache-0.4.1/bench/live/2026-11-30-haiku-claude-code.json +36 -0
  5. ctxcache-0.4.1/bench/live/2026-11-30-model-proof.json +154 -0
  6. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/BENCH.md +14 -1
  7. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/CLAIMS.md +2 -0
  8. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/METRICS.md +1 -1
  9. {ctxcache-0.4.0 → ctxcache-0.4.1}/pyproject.toml +1 -1
  10. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/adapters/anthropic.py +8 -5
  11. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/wrapper.py +1 -1
  12. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_invariants.py +11 -10
  13. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_observe_wire.py +27 -0
  14. {ctxcache-0.4.0 → ctxcache-0.4.1}/.githooks/pre-push +0 -0
  15. {ctxcache-0.4.0 → ctxcache-0.4.1}/.github/workflows/bedrock-probe.yml +0 -0
  16. {ctxcache-0.4.0 → ctxcache-0.4.1}/.github/workflows/ci.yml +0 -0
  17. {ctxcache-0.4.0 → ctxcache-0.4.1}/.github/workflows/contract.yml +0 -0
  18. {ctxcache-0.4.0 → ctxcache-0.4.1}/.github/workflows/live-session.yml +0 -0
  19. {ctxcache-0.4.0 → ctxcache-0.4.1}/.github/workflows/release.yml +0 -0
  20. {ctxcache-0.4.0 → ctxcache-0.4.1}/.gitignore +0 -0
  21. {ctxcache-0.4.0 → ctxcache-0.4.1}/CLAUDE.md +0 -0
  22. {ctxcache-0.4.0 → ctxcache-0.4.1}/DELIVERY.md +0 -0
  23. {ctxcache-0.4.0 → ctxcache-0.4.1}/LICENSE +0 -0
  24. {ctxcache-0.4.0 → ctxcache-0.4.1}/Makefile +0 -0
  25. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/bedrock_probe.py +0 -0
  26. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/live/2026-11-12-broad.json +0 -0
  27. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/live/2026-11-12-tools.json +0 -0
  28. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/live/2026-11-12.json +0 -0
  29. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/live_broad.py +0 -0
  30. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/live_session.py +0 -0
  31. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/live_summary.py +0 -0
  32. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m0/__init__.py +0 -0
  33. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m0/arms.py +0 -0
  34. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m0/runner.py +0 -0
  35. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m2/compaction_study.py +0 -0
  36. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m2/runner.py +0 -0
  37. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m3/runner.py +0 -0
  38. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m4/freeze_report.py +0 -0
  39. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m4/runner.py +0 -0
  40. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m5/runner.py +0 -0
  41. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/m6/runner.py +0 -0
  42. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/render_live.py +0 -0
  43. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/tasks/__init__.py +0 -0
  44. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/tasks/base.py +0 -0
  45. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/tasks/memory.py +0 -0
  46. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/tasks/mixed.py +0 -0
  47. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/tasks/registry.py +0 -0
  48. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/templates/__init__.py +0 -0
  49. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/templates/minimal.py +0 -0
  50. {ctxcache-0.4.0 → ctxcache-0.4.1}/bench/templates/typical.py +0 -0
  51. {ctxcache-0.4.0 → ctxcache-0.4.1}/ctxcache-live-session.html +0 -0
  52. {ctxcache-0.4.0 → ctxcache-0.4.1}/ctxcache-scenarios.html +0 -0
  53. {ctxcache-0.4.0 → ctxcache-0.4.1}/ctxcache-synthesis.html +0 -0
  54. {ctxcache-0.4.0 → ctxcache-0.4.1}/ctxcache-v0.1-proof.html +0 -0
  55. {ctxcache-0.4.0 → ctxcache-0.4.1}/ctxcache-v0.1-proof.typescript +0 -0
  56. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/ADOPTION_BASELINE.md +0 -0
  57. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/BREAKS.md +0 -0
  58. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/BUILD_HANDBOOK.md +0 -0
  59. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/DECISIONS.md +0 -0
  60. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/LIMITS.md +0 -0
  61. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/PYPI.md +0 -0
  62. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/REPORT.md +0 -0
  63. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/REPRODUCE.md +0 -0
  64. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/STATUS.md +0 -0
  65. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/hdiagrams/g1_funnel.svg +0 -0
  66. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/hdiagrams/g2_flywheel.svg +0 -0
  67. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/hdiagrams/h1_arch.svg +0 -0
  68. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/hdiagrams/h2_layout.svg +0 -0
  69. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/hdiagrams/h3_call.svg +0 -0
  70. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/hdiagrams/h4_plan.svg +0 -0
  71. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/media/ctxcache-cost-proof-preview.gif +0 -0
  72. {ctxcache-0.4.0 → ctxcache-0.4.1}/docs/media/ctxcache-cost-proof.mp4 +0 -0
  73. {ctxcache-0.4.0 → ctxcache-0.4.1}/examples/01_quickstart_openai.py +0 -0
  74. {ctxcache-0.4.0 → ctxcache-0.4.1}/examples/02_fastapi_streaming_service.py +0 -0
  75. {ctxcache-0.4.0 → ctxcache-0.4.1}/examples/03_opentelemetry_tracing.py +0 -0
  76. {ctxcache-0.4.0 → ctxcache-0.4.1}/examples/README.md +0 -0
  77. {ctxcache-0.4.0 → ctxcache-0.4.1}/examples/github-action/workflow.yml +0 -0
  78. {ctxcache-0.4.0 → ctxcache-0.4.1}/experiments/2026-11-30-m4-sim/RECORD.md +0 -0
  79. {ctxcache-0.4.0 → ctxcache-0.4.1}/experiments/2026-11-30-m4-sim/stdout.txt +0 -0
  80. {ctxcache-0.4.0 → ctxcache-0.4.1}/experiments/RECORD_TEMPLATE.md +0 -0
  81. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/CLAIMS.md +0 -0
  82. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/GTM_HANDBOOK.md +0 -0
  83. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/SCOREBOARD.md +0 -0
  84. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/hdiagrams/g1_funnel.svg +0 -0
  85. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/hdiagrams/g2_flywheel.svg +0 -0
  86. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/hdiagrams/h1_arch.svg +0 -0
  87. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/hdiagrams/h2_layout.svg +0 -0
  88. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/hdiagrams/h3_call.svg +0 -0
  89. {ctxcache-0.4.0 → ctxcache-0.4.1}/gtm/hdiagrams/h4_plan.svg +0 -0
  90. {ctxcache-0.4.0 → ctxcache-0.4.1}/prompts/BUILD_AGENT_PROMPT.md +0 -0
  91. {ctxcache-0.4.0 → ctxcache-0.4.1}/prompts/GTM_AGENT_PROMPT.md +0 -0
  92. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/__init__.py +0 -0
  93. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/adapters/__init__.py +0 -0
  94. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/adapters/base.py +0 -0
  95. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/adapters/bedrock.py +0 -0
  96. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/adapters/gemini.py +0 -0
  97. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/adapters/openai.py +0 -0
  98. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/bedrock_converse.py +0 -0
  99. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/bench/__init__.py +0 -0
  100. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/bench/runner.py +0 -0
  101. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/cli.py +0 -0
  102. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/compaction.py +0 -0
  103. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/cost.py +0 -0
  104. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/data/breaks.yaml +0 -0
  105. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/data/providers.toml +0 -0
  106. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/demo.py +0 -0
  107. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/exceptions.py +0 -0
  108. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/fingerprint.py +0 -0
  109. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/guard.py +0 -0
  110. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/integrations/__init__.py +0 -0
  111. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/integrations/langchain.py +0 -0
  112. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/integrations/langgraph.py +0 -0
  113. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/integrations/openai_agents.py +0 -0
  114. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/integrations/pydantic_ai.py +0 -0
  115. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/layout.py +0 -0
  116. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/ledger.py +0 -0
  117. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/memory/__init__.py +0 -0
  118. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/memory/checks.py +0 -0
  119. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/memory/recall.py +0 -0
  120. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/memory/store.py +0 -0
  121. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/offload.py +0 -0
  122. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/openai_chat.py +0 -0
  123. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/otel.py +0 -0
  124. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/planner.py +0 -0
  125. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/policies/__init__.py +0 -0
  126. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/policies/route.py +0 -0
  127. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/replay.py +0 -0
  128. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/scenarios.py +0 -0
  129. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/segments.py +0 -0
  130. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/sim/__init__.py +0 -0
  131. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/sim/cache_sim.py +0 -0
  132. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/sim/tokens.py +0 -0
  133. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/testing.py +0 -0
  134. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/tools.py +0 -0
  135. {ctxcache-0.4.0 → ctxcache-0.4.1}/src/ctxcache/trace.py +0 -0
  136. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/__init__.py +0 -0
  137. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/fixtures/check_clean.py +0 -0
  138. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/fixtures/check_reorder.py +0 -0
  139. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_bedrock_converse.py +0 -0
  140. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_chat_optimize.py +0 -0
  141. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_cli.py +0 -0
  142. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_compaction.py +0 -0
  143. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_contract.py +0 -0
  144. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_guard.py +0 -0
  145. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_integrations.py +0 -0
  146. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_live_summary.py +0 -0
  147. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_memory.py +0 -0
  148. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_named_tests_exist.py +0 -0
  149. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_otel.py +0 -0
  150. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_outbound.py +0 -0
  151. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_perf.py +0 -0
  152. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_planner.py +0 -0
  153. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_routing.py +0 -0
  154. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_scenarios.py +0 -0
  155. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_sim.py +0 -0
  156. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_stream.py +0 -0
  157. {ctxcache-0.4.0 → ctxcache-0.4.1}/tests/test_testing.py +0 -0
  158. {ctxcache-0.4.0 → ctxcache-0.4.1}/uv.lock +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ - Anthropic `input_tokens` is the uncached tail. A cache read no longer raises after the provider has answered.
6
+ - A recording error on a normal call returns the provider response.
7
+ - `safe` mode does not write Anthropic `cache_control`. The README says so.
8
+ - The README records the one Haiku clock comparison from 2026-11-30.
9
+
3
10
  ## 0.4.0
4
11
 
5
12
  - `ctxcache demo` runs offline: three named cache breaks, a simulator price, then the fix.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ctxcache
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: Embeddable context engine that keeps an AI agent's prompt cache warm and proves it with measurements.
5
5
  Author-email: Abhranshu <abhranshu@atnms.ai>
6
6
  License-Expression: Apache-2.0
@@ -53,6 +53,10 @@ LIVE, one Kimi K3 session: the standing document, no-cache vs cached cost, the b
53
53
 
54
54
  [`bench/live/2026-11-12-tools.json`](bench/live/2026-11-12-tools.json) is the tool session: one tool description changed, and the cache-read count on that turn stayed high.
55
55
 
56
+ LIVE, 2026-11-30, the same short prompt twice: Nova Micro, Nova Lite, Nova Pro, and Kimi K3 returned a cache read on the second call. gpt-oss returned no cache field, and both of those calls cost **$0.00014265**. A clock on the first line of the Nova Micro prompt dropped the read to 0. Receipt: [`bench/live/2026-11-30-model-proof.json`](bench/live/2026-11-30-model-proof.json). This run cost **$0.00525445**.
57
+
58
+ LIVE, the same day, one new clock on a Haiku 5.5 prompt: `safe` cost **$0.00124700** and read 0 cached tokens. `optimize` moved the clock and cost **$0.00035128**, with 4,728 tokens read from cache. That call cost **$0.00089572** less. Claude Code had already turned caching on. Receipt: [`bench/live/2026-11-30-haiku-claude-code.json`](bench/live/2026-11-30-haiku-claude-code.json).
59
+
56
60
  ![CtxCache measured proof](docs/media/ctxcache-cost-proof-preview.gif)
57
61
 
58
62
  [Full MP4 (~81s)](docs/media/ctxcache-cost-proof.mp4) · [Release download](https://github.com/jishmisc28/ctxcache/releases/download/proof-video/ctxcache-cost-proof.mp4) · [Live session write-up](docs/REPORT.md)
@@ -78,11 +82,9 @@ CtxCache wraps your existing LLM client in-process, measures cache behavior, res
78
82
  ## Installation
79
83
 
80
84
  ```bash
81
- pip install "ctxcache @ git+https://github.com/jishmisc28/ctxcache.git@v0.4.0"
85
+ pip install ctxcache
82
86
  ```
83
87
 
84
- PyPI still serves 0.3.0. That upload does not contain `ctxcache demo`. Use the command above until 0.4.0 is on PyPI.
85
-
86
88
  Run this first. No API key and no network. The prices are the simulator, not a provider bill.
87
89
 
88
90
  ```bash
@@ -100,7 +102,7 @@ ctxcache scenarios --html ctxcache-scenarios.html
100
102
 
101
103
  On Amazon Bedrock the Chat Completions URL that answers is `https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions`, and the gpt-oss-120b id is `openai.gpt-oss-120b-1:0`. On 2 Nov 2026 two identical 1,699-token prompts came back with no cached-token field. Optimize mode still moves a clock out of the system message. It does not invent a cache discount the provider did not report.
102
104
 
103
- Nova Micro on the Converse API did return a cache read. Through `ctxcache.wrap` in observe mode, the second identical call reported 3,601 cached input tokens and 6 uncached tokens. The dollar cost is not stated here, because this model has no sourced price in `providers.toml` yet.
105
+ Nova Micro on the Converse API did return a cache read. Through `ctxcache.wrap` in observe mode, the second identical call reported 3,601 cached input tokens and 6 uncached tokens. The priced Nova calls are the 2026-11-30 receipt above.
104
106
 
105
107
  Optional provider and integration extras:
106
108
  ```bash
@@ -130,7 +132,7 @@ response = client.messages.create(
130
132
  ```
131
133
 
132
134
  ### 2. `safe` Mode (Content-Equivalent Stabilization)
133
- Adds, removes, or modifies no prompt or tool text (claim C-04). Restores the first-seen tool order and injects cache breakpoints/metadata strictly matching provider rules (e.g. Anthropic `cache_control` breakpoints, OpenAI cache keys).
135
+ Adds, removes, or modifies no prompt or tool text (claim C-04). Restores the first-seen tool order. On OpenAI it can set `prompt_cache_key`. It does not write Anthropic `cache_control` blocks.
134
136
 
135
137
  ```python
136
138
  client = ctxcache.wrap(Anthropic(), mode="safe")
@@ -21,6 +21,10 @@ LIVE, one Kimi K3 session: the standing document, no-cache vs cached cost, the b
21
21
 
22
22
  [`bench/live/2026-11-12-tools.json`](bench/live/2026-11-12-tools.json) is the tool session: one tool description changed, and the cache-read count on that turn stayed high.
23
23
 
24
+ LIVE, 2026-11-30, the same short prompt twice: Nova Micro, Nova Lite, Nova Pro, and Kimi K3 returned a cache read on the second call. gpt-oss returned no cache field, and both of those calls cost **$0.00014265**. A clock on the first line of the Nova Micro prompt dropped the read to 0. Receipt: [`bench/live/2026-11-30-model-proof.json`](bench/live/2026-11-30-model-proof.json). This run cost **$0.00525445**.
25
+
26
+ LIVE, the same day, one new clock on a Haiku 5.5 prompt: `safe` cost **$0.00124700** and read 0 cached tokens. `optimize` moved the clock and cost **$0.00035128**, with 4,728 tokens read from cache. That call cost **$0.00089572** less. Claude Code had already turned caching on. Receipt: [`bench/live/2026-11-30-haiku-claude-code.json`](bench/live/2026-11-30-haiku-claude-code.json).
27
+
24
28
  ![CtxCache measured proof](docs/media/ctxcache-cost-proof-preview.gif)
25
29
 
26
30
  [Full MP4 (~81s)](docs/media/ctxcache-cost-proof.mp4) · [Release download](https://github.com/jishmisc28/ctxcache/releases/download/proof-video/ctxcache-cost-proof.mp4) · [Live session write-up](docs/REPORT.md)
@@ -46,11 +50,9 @@ CtxCache wraps your existing LLM client in-process, measures cache behavior, res
46
50
  ## Installation
47
51
 
48
52
  ```bash
49
- pip install "ctxcache @ git+https://github.com/jishmisc28/ctxcache.git@v0.4.0"
53
+ pip install ctxcache
50
54
  ```
51
55
 
52
- PyPI still serves 0.3.0. That upload does not contain `ctxcache demo`. Use the command above until 0.4.0 is on PyPI.
53
-
54
56
  Run this first. No API key and no network. The prices are the simulator, not a provider bill.
55
57
 
56
58
  ```bash
@@ -68,7 +70,7 @@ ctxcache scenarios --html ctxcache-scenarios.html
68
70
 
69
71
  On Amazon Bedrock the Chat Completions URL that answers is `https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions`, and the gpt-oss-120b id is `openai.gpt-oss-120b-1:0`. On 2 Nov 2026 two identical 1,699-token prompts came back with no cached-token field. Optimize mode still moves a clock out of the system message. It does not invent a cache discount the provider did not report.
70
72
 
71
- Nova Micro on the Converse API did return a cache read. Through `ctxcache.wrap` in observe mode, the second identical call reported 3,601 cached input tokens and 6 uncached tokens. The dollar cost is not stated here, because this model has no sourced price in `providers.toml` yet.
73
+ Nova Micro on the Converse API did return a cache read. Through `ctxcache.wrap` in observe mode, the second identical call reported 3,601 cached input tokens and 6 uncached tokens. The priced Nova calls are the 2026-11-30 receipt above.
72
74
 
73
75
  Optional provider and integration extras:
74
76
  ```bash
@@ -98,7 +100,7 @@ response = client.messages.create(
98
100
  ```
99
101
 
100
102
  ### 2. `safe` Mode (Content-Equivalent Stabilization)
101
- Adds, removes, or modifies no prompt or tool text (claim C-04). Restores the first-seen tool order and injects cache breakpoints/metadata strictly matching provider rules (e.g. Anthropic `cache_control` breakpoints, OpenAI cache keys).
103
+ Adds, removes, or modifies no prompt or tool text (claim C-04). Restores the first-seen tool order. On OpenAI it can set `prompt_cache_key`. It does not write Anthropic `cache_control` blocks.
102
104
 
103
105
  ```python
104
106
  client = ctxcache.wrap(Anthropic(), mode="safe")
@@ -0,0 +1,36 @@
1
+ {
2
+ "date": "2026-11-30",
3
+ "model": "claude-haiku-5-5",
4
+ "path": "Claude Code CLI 2.1.332, claude -p --output-format json. A thin client forwarded that usage into ctxcache.wrap.",
5
+ "price_url": "https://platform.claude.com/docs/en/about-claude/pricing",
6
+ "price_read_on": "2026-11-30",
7
+ "prices_per_million": {
8
+ "input": "0.10",
9
+ "cache_write_1h": "0.20",
10
+ "cache_read": "0.01",
11
+ "output": "0.50"
12
+ },
13
+ "note": "The CLI set its own 1-hour cache_control and added its own tokens. About 1,000 of those tokens changed on every call. The raw stdout stayed on the machine that ran Claude Code. The dollars below were recomputed from the reported token fields and the price page, and they matched.",
14
+ "calls": [
15
+ {
16
+ "call": "new clock, safe",
17
+ "input_tokens": 2,
18
+ "cache_write_input_tokens": 6224,
19
+ "cache_read_input_tokens": 0,
20
+ "output_tokens": 4,
21
+ "usd": "0.00124700"
22
+ },
23
+ {
24
+ "call": "new clock, optimize",
25
+ "input_tokens": 2,
26
+ "cache_write_input_tokens": 1509,
27
+ "cache_read_input_tokens": 4728,
28
+ "output_tokens": 4,
29
+ "usd": "0.00035128",
30
+ "note": "optimize moved the clock out of the system text. This clock value had not been sent before."
31
+ }
32
+ ],
33
+ "difference_usd": "0.00089572",
34
+ "session_total_usd": "0.00852512",
35
+ "session_calls": 17
36
+ }
@@ -0,0 +1,154 @@
1
+ {
2
+ "date": "2026-11-30",
3
+ "region": "us-east-1",
4
+ "aws_profile": "tieot",
5
+ "api": "bedrock-runtime converse",
6
+ "client": "aws cli. These calls did not go through ctxcache.wrap.",
7
+ "price_source": "src/ctxcache/data/providers.toml",
8
+ "spent_priced_usd": "0.00525445",
9
+ "prompt": "System text is 'The repository rule is stable. ' repeated 140 times. User text is 'Reply with the single word ok.'",
10
+ "results": [
11
+ {
12
+ "model": "amazon.nova-micro-v1:0",
13
+ "cache_checkpoint": true,
14
+ "calls": [
15
+ {
16
+ "call": "stable-1",
17
+ "input_tokens": 6,
18
+ "cache_read_input_tokens": 0,
19
+ "cache_write_input_tokens": 841,
20
+ "output_tokens": 2,
21
+ "usd": "0.00000049",
22
+ "uncached_baseline_usd": "0.00002993"
23
+ },
24
+ {
25
+ "call": "stable-2",
26
+ "input_tokens": 6,
27
+ "cache_read_input_tokens": 841,
28
+ "cache_write_input_tokens": 0,
29
+ "output_tokens": 2,
30
+ "usd": "0.00000785",
31
+ "uncached_baseline_usd": "0.00002993"
32
+ },
33
+ {
34
+ "call": "clock",
35
+ "note": "The system text starts with 'Current time: 2026-11-30T23:50:00'.",
36
+ "input_tokens": 6,
37
+ "cache_read_input_tokens": 0,
38
+ "cache_write_input_tokens": 865,
39
+ "output_tokens": 2,
40
+ "usd": "0.00000049",
41
+ "uncached_baseline_usd": "0.00003077"
42
+ }
43
+ ]
44
+ },
45
+ {
46
+ "model": "amazon.nova-lite-v1:0",
47
+ "cache_checkpoint": true,
48
+ "calls": [
49
+ {
50
+ "call": "stable-1",
51
+ "input_tokens": 6,
52
+ "cache_read_input_tokens": 0,
53
+ "cache_write_input_tokens": 841,
54
+ "output_tokens": 3,
55
+ "usd": "0.00000108",
56
+ "uncached_baseline_usd": "0.00005154"
57
+ },
58
+ {
59
+ "call": "stable-2",
60
+ "input_tokens": 6,
61
+ "cache_read_input_tokens": 841,
62
+ "cache_write_input_tokens": 0,
63
+ "output_tokens": 3,
64
+ "usd": "0.00001370",
65
+ "uncached_baseline_usd": "0.00005154"
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ "model": "amazon.nova-pro-v1:0",
71
+ "cache_checkpoint": true,
72
+ "calls": [
73
+ {
74
+ "call": "stable-1",
75
+ "input_tokens": 6,
76
+ "cache_read_input_tokens": 0,
77
+ "cache_write_input_tokens": 841,
78
+ "output_tokens": 3,
79
+ "usd": "0.00001440",
80
+ "uncached_baseline_usd": "0.00068720"
81
+ },
82
+ {
83
+ "call": "stable-2",
84
+ "input_tokens": 6,
85
+ "cache_read_input_tokens": 841,
86
+ "cache_write_input_tokens": 0,
87
+ "output_tokens": 3,
88
+ "usd": "0.00018260",
89
+ "uncached_baseline_usd": "0.00068720"
90
+ }
91
+ ]
92
+ },
93
+ {
94
+ "model": "us.moonshotai.kimi-k3",
95
+ "cache_checkpoint": false,
96
+ "note": "This model rejects cachePoint. maxTokens is 16 because the model rejects a lower cap. The first call costs more than its uncached baseline because the price row charges a cache write at 1.25x.",
97
+ "calls": [
98
+ {
99
+ "call": "stable-1",
100
+ "input_tokens": 7,
101
+ "cache_read_input_tokens": 0,
102
+ "cache_write_input_tokens": 937,
103
+ "output_tokens": 16,
104
+ "usd": "0.00415223",
105
+ "uncached_baseline_usd": "0.00337920"
106
+ },
107
+ {
108
+ "call": "stable-2",
109
+ "input_tokens": 7,
110
+ "cache_read_input_tokens": 937,
111
+ "cache_write_input_tokens": 0,
112
+ "output_tokens": 16,
113
+ "usd": "0.00059631",
114
+ "uncached_baseline_usd": "0.00337920"
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ "model": "openai.gpt-oss-120b-1:0",
120
+ "cache_checkpoint": false,
121
+ "note": "A request with cachePoint was refused. These two calls omit it. The response usage has no cache-read field and no cache-write field.",
122
+ "calls": [
123
+ {
124
+ "call": "stable-1",
125
+ "input_tokens": 919,
126
+ "cache_read_input_tokens": null,
127
+ "cache_write_input_tokens": null,
128
+ "output_tokens": 8,
129
+ "usd": "0.00014265",
130
+ "uncached_baseline_usd": "0.00014265"
131
+ },
132
+ {
133
+ "call": "stable-2",
134
+ "input_tokens": 919,
135
+ "cache_read_input_tokens": null,
136
+ "cache_write_input_tokens": null,
137
+ "output_tokens": 8,
138
+ "usd": "0.00014265",
139
+ "uncached_baseline_usd": "0.00014265"
140
+ }
141
+ ]
142
+ }
143
+ ],
144
+ "blocked": [
145
+ {
146
+ "model": "us.anthropic.claude-haiku-4-5-20251001-v1:0",
147
+ "result": "ResourceNotFoundException: Anthropic use-case details have not been submitted for this account."
148
+ },
149
+ {
150
+ "model": "us.xai.grok-4.7",
151
+ "result": "AccessDeniedException: model is not available for this account."
152
+ }
153
+ ]
154
+ }
@@ -6,7 +6,7 @@ Tracks live provider calls, token totals, and spend against approved budget (D-0
6
6
 
7
7
  - **Approved M0 + Contract Test Budget:** $25.00
8
8
  - **Approved GTM Budget:** $30.00
9
- - **Total Spent to Date:** $0.98023148 priced. One Claude Haiku 4.5 call is listed in tokens only, because that model has no price row.
9
+ - **Total Spent to Date:** $0.98548593 priced. One Claude Haiku 4.5 call is listed in tokens only, because that model has no price row.
10
10
 
11
11
  ## Spend Log
12
12
 
@@ -39,6 +39,17 @@ Tracks live provider calls, token totals, and spend against approved budget (D-0
39
39
  | 2026-11-12 | 43269713464 | short probe | us.moonshotai.kimi-k3 | 103 | 0 | 32 | 0.00086790 | 0.00997610 |
40
40
  | 2026-11-12 | 43269713464 | agent session, 7 turns | us.moonshotai.kimi-k3 | 672725 | 480390 read, 192159 written | 224 | 0.95546138 | 0.96543748 |
41
41
  | 2026-11-12 | 43269713464 | agent session, 7 turns | amazon.nova-pro-v1:0 | 100853 | 72006 read, 28804 written | 112 | 0.01479400 | 0.98023148 |
42
+ | 2026-11-30 | model-proof | same short prompt, call 1 | amazon.nova-micro-v1:0 | 847 | 0 read, 841 written | 2 | 0.00000049 | 0.98023197 |
43
+ | 2026-11-30 | model-proof | same short prompt, call 2 | amazon.nova-micro-v1:0 | 847 | 841 | 2 | 0.00000785 | 0.98023982 |
44
+ | 2026-11-30 | model-proof | clock on the first line | amazon.nova-micro-v1:0 | 871 | 0 read, 865 written | 2 | 0.00000049 | 0.98024031 |
45
+ | 2026-11-30 | model-proof | same short prompt, call 1 | amazon.nova-lite-v1:0 | 847 | 0 read, 841 written | 3 | 0.00000108 | 0.98024139 |
46
+ | 2026-11-30 | model-proof | same short prompt, call 2 | amazon.nova-lite-v1:0 | 847 | 841 | 3 | 0.00001370 | 0.98025509 |
47
+ | 2026-11-30 | model-proof | same short prompt, call 1 | amazon.nova-pro-v1:0 | 847 | 0 read, 841 written | 3 | 0.00001440 | 0.98026949 |
48
+ | 2026-11-30 | model-proof | same short prompt, call 2 | amazon.nova-pro-v1:0 | 847 | 841 | 3 | 0.00018260 | 0.98045209 |
49
+ | 2026-11-30 | model-proof | same short prompt, no cache field | openai.gpt-oss-120b-1:0 | 919 | 0 (field absent) | 8 | 0.00014265 | 0.98059474 |
50
+ | 2026-11-30 | model-proof | same short prompt, no cache field | openai.gpt-oss-120b-1:0 | 919 | 0 (field absent) | 8 | 0.00014265 | 0.98073739 |
51
+ | 2026-11-30 | model-proof | same short prompt, call 1, write at 1.25x | us.moonshotai.kimi-k3 | 944 | 0 read, 937 written | 16 | 0.00415223 | 0.98488962 |
52
+ | 2026-11-30 | model-proof | same short prompt, call 2 | us.moonshotai.kimi-k3 | 944 | 937 | 16 | 0.00059631 | 0.98548593 |
42
53
 
43
54
  The second identical 1,699-token gpt-oss prompt returned the same usage as the first. No `cached_tokens` field was present. A clock prefixed to that prompt changed the billed input from 1,699 to 1,716. `DeepSeek-V3.1` (`deepseek.v3-v1:0` and `deepseek.v3.1`) was rejected as an invalid model id on this key.
44
55
 
@@ -52,6 +63,8 @@ On 2026-11-12 run `43269713464` raised the cap to $5 and called the models this
52
63
 
53
64
  The same day, a tool session kept that checkpoint on the instructions and sent three tools. The first two attempts were rejected by Nova with HTTP 424, an invalid tool sequence, after the cache had been written. Those calls cost $0.00078748. Run `43264643293` then completed six turns on Nova Micro and Nova Lite. Turn 1 read the 13,266 tokens written by the first attempt. The sixth turn changed one tool description and the cache read stayed: 13,336 of 13,884 on Nova Micro, and 13,300 of 13,776 on Nova Lite. The per-turn counts are in `bench/live/2026-11-12-tools.json`. This run added $0.00220211.
54
65
 
66
+ On 2026-11-30 the same short prompt was sent twice through Bedrock Converse on the `tieot` profile in us-east-1. The calls used the AWS CLI, not `ctxcache.wrap`. Nova Micro, Nova Lite, and Nova Pro each wrote 841 tokens and then read 841. Nova Micro and Nova Lite match the 2026-11-11 probe on those counts. A clock on the first line of the Nova Micro prompt wrote 865 and read 0. Kimi K3 rejects `cachePoint`; without it, the first call wrote 937 tokens at the 1.25× write price ($0.00415223 against an uncached $0.00337920) and the second read 937 ($0.00059631 against $0.00337920). gpt-oss rejected the caching request; without it, both calls cost $0.00014265 and the response had no cache field. Claude Haiku 4.5 was refused until the Anthropic use-case form is submitted. Grok 4.7 is not enabled on this account. The receipt is `bench/live/2026-11-30-model-proof.json`. This run added $0.00525445.
67
+
55
68
  On 2026-11-11 a manual probe under a $1 ceiling called Nova again and tried Claude. Nova Micro's two calls cost $0.00000834 against an uncached pair of $0.00005986. Nova Lite's two calls cost $0.00001478 against $0.00010308. On each second call, 841 of 847 input tokens were a cache read. Claude Haiku 5.5 returned HTTP 403, not enabled for this account. Claude 3 Haiku and Claude 3.5 Haiku returned HTTP 404, end of life. Claude Haiku 4.5 answered once: 3,915 input tokens and no cache write, short of that model's 4,096-token cache minimum. The next Haiku 4.5 call returned HTTP 404 asking for the Anthropic use-case form. No dollar figure is stated for that call.
56
69
 
57
70
  ## Pre-Registered M0 Tasks & Models
@@ -12,6 +12,8 @@ Tags:
12
12
  | Claim | Tag | Source | Date | What it does not mean |
13
13
  |---|---|---|---|---|
14
14
  | Paid $0.95546138, uncached $2.22368850, saved $1.26822712 | LIVE | `bench/live/2026-11-12-broad.json` (`actual_usd`, `baseline_usd`, `saved_usd`). Also `docs/BENCH.md`. | 2026-11-12 | One Kimi K3 session (`us.moonshotai.kimi-k3`, GitHub Actions run `43269713464`). Not a monthly bill. Not the 42% table. |
15
+ | 2026-11-30 short-prompt pair: Nova Micro, Nova Lite, Nova Pro, and Kimi K3 cache-read on call 2; gpt-oss both calls $0.00014265; run cost $0.00525445 | LIVE | `bench/live/2026-11-30-model-proof.json`. Dollars from `src/ctxcache/data/providers.toml`. Also `docs/BENCH.md`. | 2026-11-30 | AWS CLI Converse calls, not `ctxcache.wrap`. Not a monthly bill. Not the 42% table. Kimi call 1 cost more than its uncached baseline because the write price is 1.25×. |
16
+ | Haiku 5.5, one new clock: safe $0.00124700, optimize $0.00035128, difference $0.00089572 | LIVE | `bench/live/2026-11-30-haiku-claude-code.json`. Prices from the Claude pricing page read that day. | 2026-11-30 | One call each. Claude Code set `cache_control`. The library moved the clock. The raw stdout is not in this repo. Not a monthly bill. Not the 42% table. |
15
17
  | Prompt caching cuts input cost and TTFT by up to 90% | none | `README.md` only. No measurement file in this repo. | none | Not a CtxCache result. Not LIVE and not SIM. |
16
18
  | Pure Python on 3.11+, `tomli` on 3.10 | none | `pyproject.toml` `requires-python = ">=3.10"` and the `tomli` marker. | 2026-11-23 (PyPI 0.3.0) | The badge says 3.10+. The library is not 3.11-only. |
17
19
  | Added latency under 2.0 ms at 50,000 tokens | MICROBENCH | `tests/test_perf.py` asserts p50 ≤ 2.0 ms and p99 ≤ 5.0 ms, GC disabled, 100 loops. | the commit that contains that test | A budget check. It does not record 0.66 ms. |
@@ -44,7 +44,7 @@ $$\text{total\_input} = \text{read} + \text{write} + \text{uncached}$$
44
44
  - `input_tokens` $\rightarrow$ `total_input`
45
45
  - `cache_read_input_tokens` $\rightarrow$ `read`
46
46
  - `cache_creation_input_tokens` $\rightarrow$ `write`
47
- - `uncached = input_tokens - read - write`
47
+ - `uncached = input_tokens`. Cache read and cache write are not inside that field. `total_input = input_tokens + cache_read_input_tokens + cache_creation_input_tokens`.
48
48
  - **OpenAI:**
49
49
  - `prompt_tokens` $\rightarrow$ `total_input`
50
50
  - `prompt_tokens_details.cached_tokens` $\rightarrow$ `read`
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "ctxcache"
7
- version = "0.4.0"
7
+ version = "0.4.1"
8
8
  description = "Embeddable context engine that keeps an AI agent's prompt cache warm and proves it with measurements."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -8,7 +8,12 @@ from ctxcache.adapters.base import NormalizedUsage
8
8
 
9
9
 
10
10
  def parse_anthropic_usage(usage_obj: Any) -> NormalizedUsage:
11
- """Normalize Anthropic usage so read + write + uncached == input_tokens (INV-06)."""
11
+ """Normalize Anthropic usage.
12
+
13
+ The live Messages API reports ``input_tokens`` as the uncached tail.
14
+ ``cache_read_input_tokens`` and ``cache_creation_input_tokens`` are
15
+ extra, not a subset of that field. The gross input is the sum.
16
+ """
12
17
  raw: dict[str, Any] = {}
13
18
  if hasattr(usage_obj, "model_dump"):
14
19
  raw = usage_obj.model_dump()
@@ -17,18 +22,16 @@ def parse_anthropic_usage(usage_obj: Any) -> NormalizedUsage:
17
22
  else:
18
23
  raw = {k: getattr(usage_obj, k) for k in dir(usage_obj) if not k.startswith("_")}
19
24
 
20
- input_tokens = int(raw.get("input_tokens", 0) or 0)
25
+ uncached = int(raw.get("input_tokens", 0) or 0)
21
26
  read = int(raw.get("cache_read_input_tokens", 0) or 0)
22
27
  write = int(raw.get("cache_creation_input_tokens", 0) or 0)
23
28
  output = int(raw.get("output_tokens", 0) or 0)
24
29
 
25
- uncached = max(0, input_tokens - read - write)
26
-
27
30
  return NormalizedUsage(
28
31
  read=read,
29
32
  write=write,
30
33
  uncached=uncached,
31
34
  output=output,
32
- total_input=input_tokens,
35
+ total_input=uncached + read + write,
33
36
  raw=raw,
34
37
  )
@@ -307,7 +307,7 @@ class WrappedMethod:
307
307
  recorded_changes=recorded_changes,
308
308
  )
309
309
 
310
- self._finalize_call(
310
+ self._finalize_quietly(
311
311
  response,
312
312
  args=args,
313
313
  kwargs=kwargs,
@@ -265,21 +265,22 @@ def test_changes_reported(tmp_path: Path) -> None:
265
265
 
266
266
 
267
267
  def test_usage_reconciles_anthropic() -> None:
268
- """INV-06: read + write + uncached equals Anthropic's total input exactly."""
268
+ """INV-06: input_tokens is the uncached tail. Cache fields are added to it."""
269
269
  from ctxcache.adapters.anthropic import parse_anthropic_usage
270
270
 
271
271
  raw = {
272
- "input_tokens": 5000,
273
- "cache_read_input_tokens": 3500,
274
- "cache_creation_input_tokens": 1000,
275
- "output_tokens": 200,
272
+ "input_tokens": 2,
273
+ "cache_read_input_tokens": 5208,
274
+ "cache_creation_input_tokens": 998,
275
+ "output_tokens": 4,
276
276
  }
277
277
  usage = parse_anthropic_usage(raw)
278
- assert usage.read + usage.write + usage.uncached == raw["input_tokens"]
279
- assert usage.read == 3500
280
- assert usage.write == 1000
281
- assert usage.uncached == 500
282
- assert usage.output == 200
278
+ assert usage.uncached == 2
279
+ assert usage.read == 5208
280
+ assert usage.write == 998
281
+ assert usage.output == 4
282
+ assert usage.total_input == 6208
283
+ assert usage.read + usage.write + usage.uncached == usage.total_input
283
284
 
284
285
 
285
286
  def test_usage_reconciles_openai() -> None:
@@ -125,6 +125,33 @@ def test_observe_anthropic_does_not_inject_a_field(isolated_home: None) -> None:
125
125
  assert sent["messages"] is messages
126
126
 
127
127
 
128
+ def test_observe_returns_live_anthropic_usage(isolated_home: None) -> None:
129
+ """A real Haiku usage object must not raise after the provider has answered."""
130
+
131
+ class Messages:
132
+ def create(self, **kwargs: Any) -> SimpleNamespace:
133
+ return SimpleNamespace(
134
+ usage={
135
+ "input_tokens": 2,
136
+ "cache_creation_input_tokens": 6207,
137
+ "cache_read_input_tokens": 0,
138
+ "output_tokens": 4,
139
+ }
140
+ )
141
+
142
+ class Root:
143
+ def __init__(self) -> None:
144
+ self.messages = Messages()
145
+
146
+ wrapped = ctxcache.wrap(Root(), mode="observe")
147
+ response = wrapped.messages.create(
148
+ model="claude-haiku-5-5",
149
+ system="rules",
150
+ messages=[{"role": "user", "content": "ok"}],
151
+ )
152
+ assert response.usage["cache_creation_input_tokens"] == 6207
153
+
154
+
128
155
  def test_observe_gemini_does_not_inject_a_field(isolated_home: None) -> None:
129
156
  root = GeminiRoot()
130
157
  contents = [{"role": "user", "parts": [{"text": "hello"}]}]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes