feat(v2): add WithPromptCaching() request option
Some checks failed
CI / Lint (push) Failing after 2m2s
CI / V2 Module (push) Failing after 2m3s
CI / Root Module (push) Has been cancelled

Introduces an opt-in RequestOption that callers can pass to enable
automatic prompt-caching markers. The option populates a cacheConfig
on requestConfig but has no effect yet — plumbing through to
provider.Request and on to the Anthropic provider lands in subsequent
commits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-09 19:17:55 +00:00
parent b4bf73136a
commit c4fe0026a2
2 changed files with 50 additions and 0 deletions

View File

@@ -135,3 +135,22 @@ func TestBuildProviderRequest_EmptyConfig(t *testing.T) {
t.Errorf("expected no tools, got %d", len(req.Tools))
}
}
func TestWithPromptCaching(t *testing.T) {
cfg := &requestConfig{}
WithPromptCaching()(cfg)
if cfg.cacheConfig == nil {
t.Fatal("expected cacheConfig to be set after WithPromptCaching()")
}
if !cfg.cacheConfig.enabled {
t.Error("expected cacheConfig.enabled to be true")
}
}
func TestWithoutPromptCaching(t *testing.T) {
cfg := &requestConfig{}
// No option applied
if cfg.cacheConfig != nil {
t.Error("expected cacheConfig to be nil when option not applied")
}
}