feat(llm): add prompt caching configuration - #724
Conversation
|
🔍 OpenCodeReview found 3 issue(s) in this PR.
[bug · medium] 📄
|
| if result.promptCaching != nil { | ||
| cfg.Llm.PromptCaching = result.promptCaching | ||
| } |
There was a problem hiding this comment.
[maintainability · low]
Potential issue: When switching from Anthropic to a non-Anthropic protocol, the old PromptCaching value remains in the config file. While this doesn't cause functional problems (the setting is only used for Anthropic), it leaves stale configuration data. Consider clearing the field when the protocol is not Anthropic:
if result.promptCaching != nil {
cfg.Llm.PromptCaching = result.promptCaching
} else if llm.NormalizeProtocol(result.protocol) != llm.ProtocolAnthropic {
cfg.Llm.PromptCaching = nil
}This same pattern appears in all three apply functions (applyManualConfig, applyCustomProviderConfig, applyOfficialProviderConfig) and should be updated consistently.
There was a problem hiding this comment.
Addressed in c07b2a7. The manual, custom, and official apply paths now clear stale prompt-caching state when the effective protocol is not Anthropic. Regression coverage includes all three switch paths and preserves the active Anthropic setting when an inactive OpenAI provider is edited.
| PromptCaching: cfg.Llm.PromptCaching, | ||
| Timeout: timeout, | ||
| }, true, nil |
There was a problem hiding this comment.
[maintainability · low]
Inconsistent sourcing: PromptCaching is read from cfg.Llm.PromptCaching (the top-level llm block), while other analogous per-provider fields like ExtraBody, ExtraHeaders, and TimeoutSec are sourced from the provider entry. Furthermore, providerEntryConfig has no PromptCaching field, so users cannot configure this setting per-provider.
If PromptCaching is intentionally a global-only setting, this is acceptable, but a brief comment explaining the design decision would prevent future confusion. Otherwise, add PromptCaching *bool to providerEntryConfig and read it from entry (falling back to cfg.Llm.PromptCaching if unset) for consistency.
There was a problem hiding this comment.
Confirmed as global by design: the toggle follows whichever Anthropic provider is active rather than being duplicated across provider entries. c07b2a7 documents that contract in both the persisted config and resolver, while keeping provider-specific transport fields on each entry.
|
I think this may duplicate #332, which adds a generalized option for prompt caching, for multiple providers. |
Summary
llm.prompt_cachingsetting while preserving the current enabled-by-default behaviorTesting
go test ./... -count=1 -skip 'TestResolveBackgroundFilePath|TestSaveConfig|TestResolveRuleEntries_SymlinkSafety|TestFinalizeSurfacesWriterCreationErrorWithoutStdout|TestHandleRepos_PermissionDenied|TestDiscoverRepos_SkipsUnreadableSubdir|TestListSessions_SkipsUnreadableFiles'go vet ./...go build -o .tmp/ocr.exe ./cmd/opencodereviewCloses #700