feat(llm): PromptCachingProvider capability — cache on renamed providers
providerSupportsCaching gated on the provider NAME being literally 'anthropic', so an Anthropic-shaped provider registered under a custom config name (platformai, bedrock, any relay) never set CacheLastMessage — every turn re-processed the full conversation history uncached (~120K input tokens and 4-6s TTFT per turn on a large session). Add llm.PromptCachingProvider capability interface; AnthropicProvider declares it; runtime gates providerSupportsCaching and providerSupportsMidLoopCompaction on the capability first, with the name check kept as legacy fallback for custom impls.
This commit is contained in:
1 parent
d5e8abf492
commit
7fa3e75ad1
4 files changed
+88
-2
No files matched your search
@@ -186,6 +186,18 @@ type NonStreamingProvider interface {
|
||||
ChatNonStreaming(ctx context.Context, req ChatRequest) (<-chan ChatEvent, error)
|
||||
}
|
||||
|
||||
// PromptCachingProvider is an optional capability interface: providers
|
||||
// that implement Anthropic-style explicit prompt caching (cache_control
|
||||
// breakpoints, CacheLastMessage) declare it here. The runtime gates
|
||||
// caching on this capability rather than on the provider's configured
|
||||
// NAME — a user-named provider block ("platformai", "bedrock", any
|
||||
// relay) wrapping an Anthropic-shaped API must still get caching;
|
||||
// matching the name string alone silently disabled it for every
|
||||
// renamed provider.
|
||||
type PromptCachingProvider interface {
|
||||
SupportsPromptCaching() bool
|
||||
}
|
||||
|
||||
// ParseProviderModel splits "provider/model" into (provider, model).
|
||||
// If no slash is present, returns ("", name) and the caller should use a default.
|
||||
func ParseProviderModel(name string) (provider, model string) {
|
||||
|
||||
Reference in new issue
Block a user