feat(v2): add WithPromptCaching() request option
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:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user