Repository navigation
Conversation
There was a problem hiding this comment.
is this file necessary? the other docs in this folder are pretty generic. While I agree that we should have documentation on this prompt caching feature, I'm not sure if this is the right place, especially when I see you mention things like the AgentBricks template. That is specific to the integration AgentBricks folder. I should not be at the top level here.
| # Claude prompt caching is enabled by default. Set to off to disable automatic cache points. | ||
| DATABRICKS_PROMPT_CACHING=auto |
There was a problem hiding this comment.
why mention claude here when the env var is named in a generic way DATABRICKS_PROMPT_CACHING?
| ## Claude prompt caching | ||
|
|
||
| Claude Chat Completions use explicit prompt cache points by default. System instructions, tool | ||
| definitions in the system prefix, and recent user/tool-result boundaries can be reused across | ||
| model calls. Set `DATABRICKS_PROMPT_CACHING=off` to opt out. Other providers keep their request | ||
| format. Cache hits require a sufficiently long, unchanged prefix within the cache lifetime; | ||
| cache writes carry an additional charge. |
There was a problem hiding this comment.
It feels weird that the Databricks prompt caching flag is only for Claude. If this is really specific to Claude, perhaps we need to rethink the name of the environment variable so we can avoid confusion?
| ## Claude prompt caching | ||
|
|
||
| Claude Chat Completions use explicit prompt cache points by default. System instructions, tool | ||
| definitions in the system prefix, and recent user/tool-result boundaries can be reused across | ||
| model calls. Set `DATABRICKS_PROMPT_CACHING=off` to opt out. Other providers keep their request | ||
| format. Cache hits require a sufficiently long, unchanged prefix within the cache lifetime; | ||
| cache writes carry an additional charge. |
Agent Bricks templates omit Claude cache controls, so repeated context can be billed as fresh input. Add a shared provider adapter in
databricks_agentkit.claudeand enable it in all four templates. Generic Databricks OpenAI/LangChain clients forward controls and normalize cache/streaming usage; they have no caching policy flags.Behavior and configuration
DATABRICKS_CLAUDE_PROMPT_CACHING=autois the template default; setoffin.envor the deployed environment to disable template placement. Other providers and unknown aliases keep their requests unchanged. Caller controls take precedence; transcripts are preserved.cache_write_tokens; native and unified cache counters merge independently, including explicit zero values.Tracks ML-70508 and ML-70509. This consolidates #746's remaining accounting fixes and regressions. #638 independently covers the streaming deduplication portion; the template adapter, cache placement, and normalization remain part of this PR.
Verification
c032ef3is documentation only: moved the template caching guide under Agent Bricks and updated references. All five guide links resolve, all four templates useDATABRICKS_CLAUDE_PROMPT_CACHING, andgit diff --checkpasses. No runtime or live tests were rerun for this documentation change.3963189. LangChain source is unchanged by the final test-only follow-up. 15 OpenAI cache-normalization tests passed at prior code heada20ce48; Ruff, formatting, focused types, and diff checks pass. The follow-up usesgetattrin the SDK extension-field assertion to fix CI compatibility. No new live/model calls were run for this consolidation. Public CI is separate.8258bc8: 288 focused SDK/adapter/template tests passed, plus 1,736 AgentKit tests, 45 generated OpenAI template tests, 44 wheel-backed functional tests, lint/type checks, and adapter compatibility tests with OpenAI 1.99.9 and 2.54. Its 54 green public checks belong to that earlier head.When adopting alongside #750, compose the cache and Gemini-signature normalizers in each shared OpenAI response hook. The historical combined test branch records this integration; it must not be merged into main.
CI on the preceding consolidation head failed only the corrected SDK-field assertion and the six memory-backed parallel-history ordering cases already reproduced on main. #582's new framework job has the same six baseline failures. No skips or forced passes were added. GitHub currently reports merge conflicts with main; the documentation revision does not resolve them.