Commit 062aff8
authored
refactor: inherit provider keys from global client in semanticcache plugin (#3079)
## Summary
The semantic cache plugin previously managed its own internal Bifrost client and required API keys to be specified directly in the plugin config. This PR removes that self-contained client and replaces it with an injected `EmbeddingRequestExecutor` — a function reference pointing to the global Bifrost client's `EmbeddingRequest` method. As a result, provider API keys are inherited automatically from the global provider configuration and no longer need to be (or can be) specified inside the plugin config.
## Changes
- Removed the `Keys []schemas.Key` field from `semanticcache.Config` and all related JSON unmarshalling, test fixtures, and UI type definitions.
- Removed the internal `PluginAccount` struct and the self-contained `bifrost.Bifrost` client that the plugin previously initialized for embedding requests.
- Introduced `EmbeddingRequestExecutor` as a function type (`func(*schemas.BifrostContext, *schemas.BifrostEmbeddingRequest) (*schemas.BifrostEmbeddingResponse, *schemas.BifrostError)`) and added `SetEmbeddingRequestExecutor` on the plugin to wire it to the global client at startup and on plugin reload.
- The server's `Bootstrap` and `ReloadPlugin` paths now call `SetEmbeddingRequestExecutor(s.Client.EmbeddingRequest)` after the plugin is loaded.
- Embedding requests generated by the plugin now run in a child context with `BifrostContextKeySkipPluginPipeline` set to `true`, preventing recursive plugin pipeline execution.
- Renamed `AddProviderKeysToSemanticCacheConfig` → `ValidateSemanticCacheConfig` to reflect that the function no longer injects keys — it only validates that the referenced provider exists in the global config.
- Removed `RemoveProviderKeysFromSemanticCacheConfig` entirely, since keys are no longer stored in the plugin config.
- Removed the `keys` field from `config.schema.json` and the UI type system (`CacheConfig`, `EditorCacheConfig`, `DirectCacheConfig`, `ProviderBackedCacheConfig`, and Zod schemas).
- Updated documentation to reflect that keys are inherited automatically, clarify UI configuration steps, and correct the direct-only mode setup instructions (omit `provider` and `embedding_model`, not `keys`).
- Updated tests to remove `Keys` from all config fixtures and adjust `TestInvalidProviderRejection` to expect `Init` to succeed (provider validation now happens at request time via the global client).
## Type of change
- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI
## Affected areas
- [ ] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [x] Plugins
- [x] UI (React)
- [x] Docs
## How to test
```sh
# Core/Transports
go test ./plugins/semanticcache/...
go test ./transports/bifrost-http/...
# UI
cd ui
pnpm i
pnpm build
```
1. Configure a provider (e.g. OpenAI) in `config.json` without specifying `keys` inside the semantic cache plugin config.
2. Enable the semantic cache plugin via the UI or `config.json`.
3. Send requests through Bifrost and confirm that semantic cache hits are returned using the global provider's keys.
4. Confirm that specifying `keys` inside the plugin config is silently ignored (field no longer exists).
## Breaking changes
- [x] Yes
- [ ] No
The `Keys` field has been removed from `semanticcache.Config`. Any existing `config.json` files or Go code that set `Keys` inside the semantic cache plugin config must remove that field. Keys are now inherited automatically from the global provider configuration and no longer need to be specified.
## Security considerations
API keys are no longer duplicated into the plugin config or persisted to the config store as part of the plugin's configuration blob. This reduces the surface area for accidental key exposure in stored configs or API responses.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable1 parent 02d0079 commit 062aff8
15 files changed
Lines changed: 1173 additions & 1206 deletions
File tree
- docs/features
- plugins/semanticcache
- transports
- bifrost-http
- handlers
- lib
- server
- ui
- app/workspace/config/views
- lib/types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | 121 | | |
123 | 122 | | |
124 | 123 | | |
| |||
155 | 154 | | |
156 | 155 | | |
157 | 156 | | |
158 | | - | |
| 157 | + | |
159 | 158 | | |
160 | | - | |
161 | | - | |
162 | | - | |
| 159 | + | |
163 | 160 | | |
164 | | - | |
| 161 | + | |
165 | 162 | | |
166 | | - | |
| 163 | + | |
167 | 164 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
172 | 168 | | |
173 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| |||
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
205 | | - | |
| 214 | + | |
206 | 215 | | |
207 | 216 | | |
208 | 217 | | |
| |||
228 | 237 | | |
229 | 238 | | |
230 | 239 | | |
231 | | - | |
| 240 | + | |
232 | 241 | | |
233 | 242 | | |
234 | 243 | | |
| |||
246 | 255 | | |
247 | 256 | | |
248 | 257 | | |
249 | | - | |
| 258 | + | |
250 | 259 | | |
251 | 260 | | |
252 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
| |||
48 | 46 | | |
49 | 47 | | |
50 | 48 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
70 | 67 | | |
71 | 68 | | |
72 | 69 | | |
73 | | - | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
| |||
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | 204 | | |
244 | 205 | | |
245 | 206 | | |
| |||
323 | 284 | | |
324 | 285 | | |
325 | 286 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
| 287 | + | |
| 288 | + | |
346 | 289 | | |
347 | 290 | | |
348 | 291 | | |
| |||
378 | 321 | | |
379 | 322 | | |
380 | 323 | | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | 324 | | |
395 | 325 | | |
396 | 326 | | |
| |||
465 | 395 | | |
466 | 396 | | |
467 | 397 | | |
468 | | - | |
| 398 | + | |
469 | 399 | | |
470 | 400 | | |
471 | 401 | | |
| |||
488 | 418 | | |
489 | 419 | | |
490 | 420 | | |
491 | | - | |
| 421 | + | |
492 | 422 | | |
493 | 423 | | |
494 | 424 | | |
| |||
759 | 689 | | |
760 | 690 | | |
761 | 691 | | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | 692 | | |
768 | 693 | | |
769 | 694 | | |
| |||
804 | 729 | | |
805 | 730 | | |
806 | 731 | | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
807 | 741 | | |
808 | 742 | | |
809 | 743 | | |
| |||
869 | 803 | | |
870 | 804 | | |
871 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
0 commit comments