Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/scripts/validate-helm-config-fields.sh
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ bifrost:
cache_by_model: true
cache_by_provider: false
exclude_system_prompt: true
cleanup_on_shutdown: true
vector_store_namespace: "bifrost-cache"
otel:
enabled: true
Expand Down Expand Up @@ -710,7 +709,6 @@ assert_field_value 'plugins: semantic_cache conversation_history_threshold' '.pl
assert_field_value 'plugins: semantic_cache cache_by_model' '.plugins.[4].config.cache_by_model' 'true'
assert_field_value 'plugins: semantic_cache cache_by_provider' '.plugins.[4].config.cache_by_provider' 'false'
assert_field_value 'plugins: semantic_cache exclude_system_prompt' '.plugins.[4].config.exclude_system_prompt' 'true'
assert_field_value 'plugins: semantic_cache cleanup_on_shutdown' '.plugins.[4].config.cleanup_on_shutdown' 'true'
assert_field_value 'plugins: semantic_cache vector_store_namespace' '.plugins.[4].config.vector_store_namespace' '"bifrost-cache"'

# OTEL plugin
Expand Down
18 changes: 9 additions & 9 deletions core/providers/anthropic/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1200,18 +1200,18 @@ const (
type AnthropicToolName string

const (
AnthropicToolNameComputer AnthropicToolName = "computer"
AnthropicToolNameWebSearch AnthropicToolName = "web_search"
AnthropicToolNameWebFetch AnthropicToolName = "web_fetch"
AnthropicToolNameBash AnthropicToolName = "bash"
AnthropicToolNameTextEditor AnthropicToolName = "str_replace_based_edit_tool"
AnthropicToolNameComputer AnthropicToolName = "computer"
AnthropicToolNameWebSearch AnthropicToolName = "web_search"
AnthropicToolNameWebFetch AnthropicToolName = "web_fetch"
AnthropicToolNameBash AnthropicToolName = "bash"
AnthropicToolNameTextEditor AnthropicToolName = "str_replace_based_edit_tool"
// AnthropicToolNameTextEditorLegacy is the name required for text_editor_20250124
// and text_editor_20250429. Newer text_editor_20250728+ use AnthropicToolNameTextEditor.
AnthropicToolNameTextEditorLegacy AnthropicToolName = "str_replace_editor"
AnthropicToolNameCodeExecution AnthropicToolName = "code_execution"
AnthropicToolNameMemory AnthropicToolName = "memory"
AnthropicToolNameToolSearchBM25 AnthropicToolName = "tool_search_tool_bm25"
AnthropicToolNameToolSearchRegex AnthropicToolName = "tool_search_tool_regex"
AnthropicToolNameCodeExecution AnthropicToolName = "code_execution"
AnthropicToolNameMemory AnthropicToolName = "memory"
AnthropicToolNameToolSearchBM25 AnthropicToolName = "tool_search_tool_bm25"
AnthropicToolNameToolSearchRegex AnthropicToolName = "tool_search_tool_regex"
)

type AnthropicToolComputerUse struct {
Expand Down
1 change: 0 additions & 1 deletion docs/deployment-guides/helm/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ Two modes:
| `bifrost.plugins.semanticCache.config.cache_by_model` | Include model name in cache key | `true` |
| `bifrost.plugins.semanticCache.config.cache_by_provider` | Include provider name in cache key | `true` |
| `bifrost.plugins.semanticCache.config.exclude_system_prompt` | Exclude system prompt from cache key | `false` |
| `bifrost.plugins.semanticCache.config.cleanup_on_shutdown` | Delete cache data on pod shutdown | `false` |

**Semantic mode (with OpenAI embeddings + Weaviate):**

Expand Down
8 changes: 0 additions & 8 deletions docs/features/semantic-caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ bifrostConfig := schemas.BifrostConfig{
"embedding_model": "text-embedding-3-small",
"dimension": 1536,

"cleanup_on_shutdown": true,
"ttl": "5m",
"threshold": 0.8,

Expand Down Expand Up @@ -281,7 +280,6 @@ bifrost:
config:
dimension: 1
ttl: "5m"
cleanup_on_shutdown: true
cache_by_model: true
cache_by_provider: true
```
Expand All @@ -299,7 +297,6 @@ bifrost:
"config": {
"dimension": 1,
"ttl": "5m",
"cleanup_on_shutdown": true,
"cache_by_model": true,
"cache_by_provider": true
}
Expand Down Expand Up @@ -671,16 +668,11 @@ The semantic cache automatically handles cleanup to prevent storage bloat:
- Clear all entries for a cache key
- Restart Bifrost to clear all cache data

<Warning>
The semantic cache namespace and all its cache entries are deleted when Bifrost client shuts down **only if `cleanup_on_shutdown` is set to `true`**. By default (`cleanup_on_shutdown: false`), cache data persists between restarts. DO NOT use the plugin's namespace for external purposes.
</Warning>

<Warning>
**Dimension / Provider / Model Changes**: A vector store namespace can only hold vectors of **one** dimension. If you change `dimension` (or switch to an embedding `provider`/`model` that produces a different vector size), the existing namespace is **not** recreated automatically — `CreateNamespace` is a no-op when the class/collection already exists. Subsequent writes will fail (vector-size mismatch) and reads will silently miss. Before saving the change, either:

- point `vector_store_namespace` at a fresh name, or
- drop the existing class/index in your vector store, or
- set `cleanup_on_shutdown: true` and restart so the old namespace is removed first.
</Warning>

---
Expand Down
54 changes: 54 additions & 0 deletions docs/migration-guides/v1.5.0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,56 @@ If you parse `cache_debug` and assumed it was either absent or had `cache_hit: t

---

## Breaking Change 16: Semantic Cache `cleanup_on_shutdown` Removed

The `cleanup_on_shutdown` option on the semantic cache plugin config has been removed. Cache entries and the vector store namespace are no longer deleted when Bifrost shuts down — cache data always persists between restarts.

**Before:**
```json
{
"plugins": {
"semantic_cache": {
"config": {
"ttl": "5m",
"cleanup_on_shutdown": true
}
}
}
}
```

**After:**
```json
{
"plugins": {
"semantic_cache": {
"config": {
"ttl": "5m"
}
}
}
}
```
Comment thread
Pratham-Mishra04 marked this conversation as resolved.

The field is no longer part of the config schema and will be rejected by validation. Remove it from `config.json`, Helm values, and any `PUT /api/config` payloads.

### How to clear cache data

If you previously relied on `cleanup_on_shutdown: true` to drop the cache on restart, use one of the supported invalidation paths instead:

- `DELETE /api/cache/clear/{cacheId}` — invalidate a single entry
- `DELETE /api/cache/clear-by-key/{cacheKey}` — invalidate all entries for a cache key
- Drop the vector store class/collection or point `vector_store_namespace` at a fresh name to start clean

### Dimension / provider / model changes

The previous `cleanup_on_shutdown: true` + restart workflow was the documented escape hatch for changing `dimension` (or switching to an embedding `provider`/`model` that produces a different vector size). That option is gone. To rotate the namespace now, either:

- point `vector_store_namespace` at a fresh name, or
- drop the existing class/index in your vector store before restarting

---

## Opting Out: `version: 1` Compatibility Mode

If you are not ready to adopt the new deny-by-default semantics, you can add a single field to `config.json` to restore v1.4.x behavior for all allow-list fields loaded from that file:
Expand Down Expand Up @@ -853,6 +903,10 @@ Remove `allow_direct_keys` from `config.json` and any `PUT /api/config` payloads
<Step title="Switch semantic cache invalidation to cache IDs">
Replace `DELETE /api/cache/clear/{requestId}` with `DELETE /api/cache/clear/{cacheId}`, and replace `plugin.ClearCacheForRequestID(...)` with `plugin.ClearCacheForCacheID(...)`. Read the cache ID from `extra_fields.cache_debug.cache_id` on the response (now populated on misses too).
</Step>

<Step title="Remove cleanup_on_shutdown from semantic cache config">
Drop the `cleanup_on_shutdown` field from the semantic cache plugin config in `config.json`, Helm values, and any API payloads — it is no longer part of the schema. Cache data now always persists across restarts; use the cache clear endpoints or rotate `vector_store_namespace` to drop entries.
</Step>
</Steps>

---
Expand Down
1 change: 0 additions & 1 deletion examples/k8s/examples/values-semantic-search-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ bifrost:
cache_by_model: true
cache_by_provider: true
exclude_system_prompt: true
cleanup_on_shutdown: false
vector_store_namespace: "bifrost-semantic-cache"

vectorStore:
Expand Down
1 change: 0 additions & 1 deletion examples/k8s/examples/values-semantic-search-weaviate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ bifrost:
cache_by_model: true
cache_by_provider: true
exclude_system_prompt: false
cleanup_on_shutdown: false
vector_store_namespace: "bifrost-semantic-cache"

vectorStore:
Expand Down
3 changes: 0 additions & 3 deletions helm-charts/bifrost/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,6 @@ false
{{- if hasKey $inputConfig "exclude_system_prompt" }}
{{- $_ := set $scConfig "exclude_system_prompt" $inputConfig.exclude_system_prompt }}
{{- end }}
{{- if hasKey $inputConfig "cleanup_on_shutdown" }}
{{- $_ := set $scConfig "cleanup_on_shutdown" $inputConfig.cleanup_on_shutdown }}
{{- end }}
{{- $plugin := dict "enabled" true "name" "semantic_cache" "config" $scConfig }}
{{- if hasKey .Values.bifrost.plugins.semanticCache "version" }}{{- $_ := set $plugin "version" (.Values.bifrost.plugins.semanticCache.version | int) }}{{- end }}
{{- $plugins = append $plugins $plugin }}
Expand Down
3 changes: 0 additions & 3 deletions helm-charts/bifrost/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,6 @@
"exclude_system_prompt": {
"type": "boolean"
},
"cleanup_on_shutdown": {
"type": "boolean"
},
"vector_store_namespace": {
"type": "string"
},
Expand Down
1 change: 0 additions & 1 deletion helm-charts/bifrost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ bifrost:
cache_by_model: true
cache_by_provider: true
exclude_system_prompt: false
cleanup_on_shutdown: false
vector_store_namespace: ""

otel:
Expand Down
44 changes: 20 additions & 24 deletions plugins/semanticcache/config_unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestUnmarshalJSON_AllFields(t *testing.T) {
input := `{
"provider": "openai",
"embedding_model": "text-embedding-3-small",
"cleanup_on_shutdown": true,
"dimension": 1536,
"ttl": "10m",
"threshold": 0.9,
Expand All @@ -66,9 +65,6 @@ func TestUnmarshalJSON_AllFields(t *testing.T) {
if config.EmbeddingModel != "text-embedding-3-small" {
t.Errorf("EmbeddingModel: expected %q, got %q", "text-embedding-3-small", config.EmbeddingModel)
}
if !config.CleanUpOnShutdown {
t.Error("CleanUpOnShutdown: expected true")
}
if config.Dimension != 1536 {
t.Errorf("Dimension: expected 1536, got %d", config.Dimension)
}
Expand Down Expand Up @@ -136,32 +132,32 @@ func TestUnmarshalJSON_TTLFormats(t *testing.T) {

func TestUnmarshalJSON_BoolPointerFields(t *testing.T) {
tests := []struct {
name string
json string
expectCacheByModel *bool
expectCacheByProv *bool
expectExcludeSys *bool
name string
json string
expectCacheByModel *bool
expectCacheByProv *bool
expectExcludeSys *bool
}{
{
name: "all set to true",
json: `{"dimension": 1536, "cache_by_model": true, "cache_by_provider": true, "exclude_system_prompt": true}`,
expectCacheByModel: bifrost.Ptr(true),
expectCacheByProv: bifrost.Ptr(true),
expectExcludeSys: bifrost.Ptr(true),
name: "all set to true",
json: `{"dimension": 1536, "cache_by_model": true, "cache_by_provider": true, "exclude_system_prompt": true}`,
expectCacheByModel: bifrost.Ptr(true),
expectCacheByProv: bifrost.Ptr(true),
expectExcludeSys: bifrost.Ptr(true),
},
{
name: "all set to false",
json: `{"dimension": 1536, "cache_by_model": false, "cache_by_provider": false, "exclude_system_prompt": false}`,
expectCacheByModel: bifrost.Ptr(false),
expectCacheByProv: bifrost.Ptr(false),
expectExcludeSys: bifrost.Ptr(false),
name: "all set to false",
json: `{"dimension": 1536, "cache_by_model": false, "cache_by_provider": false, "exclude_system_prompt": false}`,
expectCacheByModel: bifrost.Ptr(false),
expectCacheByProv: bifrost.Ptr(false),
expectExcludeSys: bifrost.Ptr(false),
},
{
name: "all omitted",
json: `{"dimension": 1536}`,
expectCacheByModel: nil,
expectCacheByProv: nil,
expectExcludeSys: nil,
name: "all omitted",
json: `{"dimension": 1536}`,
expectCacheByModel: nil,
expectCacheByProv: nil,
expectExcludeSys: nil,
},
}

Expand Down
38 changes: 0 additions & 38 deletions plugins/semanticcache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Config struct {
EmbeddingModel string `json:"embedding_model,omitempty"` // Model to use for generating embeddings (optional)

// Plugin behavior settings
CleanUpOnShutdown bool `json:"cleanup_on_shutdown,omitempty"` // Clean up cache on shutdown (default: false)
TTL time.Duration `json:"ttl,omitempty"` // Time-to-live for cached responses (default: 5min)
Threshold float64 `json:"threshold,omitempty"` // Cosine similarity threshold for semantic matching (0 = unset → default 0.8)
VectorStoreNamespace string `json:"vector_store_namespace,omitempty"` // Namespace for vector store (optional)
Expand Down Expand Up @@ -684,43 +683,6 @@ func (plugin *Plugin) Cleanup() error {
// and stopCh is still in memory. This call evicts those before we return.
plugin.cleanupOldStreamAccumulators()

// Only clean up cache entries if configured to do so
if !plugin.config.CleanUpOnShutdown {
plugin.logger.Debug("Cleanup on shutdown is disabled, skipping cache cleanup")
return nil
}

// Clean up all cache entries created by this plugin
ctx, cancel := context.WithTimeout(context.Background(), CacheSetTimeout)
defer cancel()

plugin.logger.Debug("Starting cleanup of cache entries...")

// Delete all cache entries created by this plugin
queries := []vectorstore.Query{
{
Field: "from_bifrost_semantic_cache_plugin",
Operator: vectorstore.QueryOperatorEqual,
Value: true,
},
}

results, err := plugin.store.DeleteAll(ctx, plugin.config.VectorStoreNamespace, queries)
if err != nil {
return fmt.Errorf("failed to delete cache entries: %w", err)
}

for _, result := range results {
if result.Status == vectorstore.DeleteStatusError {
plugin.logger.Warn("Failed to delete cache entry: %s", result.Error)
}
}
plugin.logger.Debug("Cleanup completed - deleted all cache entries")

if err := plugin.store.DeleteNamespace(ctx, plugin.config.VectorStoreNamespace); err != nil {
return fmt.Errorf("failed to delete namespace: %w", err)
}

return nil
}

Expand Down
Loading
Loading