Commit fec9978
authored
fix: activation memory config crashes get_default() with OpenAI (MemTensor#1051)
## Summary
Two bugs in `default_config.py` that crash `get_default()` when
`enable_activation_memory=True`:
**Bug 1: `act_mem` injected into MOSConfig (extra=forbid)**
`get_default_config()` adds `act_mem` dict to the config passed to
`MOSConfig(**config_dict)`, but `MOSConfig` has no `act_mem` field and
inherits `extra="forbid"` from `BaseConfig`:
```
pydantic_core.ValidationError: 1 validation error for MOSConfig
act_mem
Extra inputs are not permitted [type=extra_forbidden]
```
**Bug 2: KV cache with `openai` backend**
`get_default_cube_config()` hardcodes `extractor_llm` backend to
`"openai"` for KV cache memory, but `KVCacheMemoryConfig` validator
requires `huggingface`/`huggingface_singleton`/`vllm` (KV cache extracts
internal attention tensors via `build_kv_cache`, which needs local model
access):
```
ConfigurationError: KVCacheMemoryConfig requires extractor_llm backend
to be 'huggingface' or 'huggingface_singleton', got 'openai'
```
## Reproduction
```python
from memos.mem_os.utils.default_config import get_default
# This crashes with ValidationError
config, cube = get_default(
openai_api_key="sk-...",
enable_activation_memory=True,
)
```
## Fix
- Remove `act_mem` from `get_default_config()` — the
`enable_activation_memory` bool flag is sufficient for `MOSConfig`;
`act_mem` config belongs in MemCube config only.
- In `get_default_cube_config()`, require explicit
`activation_memory_backend` kwarg (e.g. `"huggingface"`) instead of
hardcoding `"openai"`. Skip `act_mem` gracefully when no compatible
local backend is provided.
## Test plan
- [ ] `get_default(openai_api_key="sk-...",
enable_activation_memory=True)` no longer crashes
- [ ] `get_default(openai_api_key="sk-...",
enable_activation_memory=True, activation_memory_backend="huggingface",
activation_memory_llm_config={...})` creates valid act_mem config
- [ ] `get_default(openai_api_key="sk-...")` continues to work as before1 file changed
+30
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
116 | 119 | | |
117 | 120 | | |
118 | 121 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
133 | 125 | | |
134 | 126 | | |
135 | 127 | | |
| |||
237 | 229 | | |
238 | 230 | | |
239 | 231 | | |
240 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
241 | 237 | | |
242 | 238 | | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
252 | 251 | | |
253 | | - | |
254 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
255 | 259 | | |
256 | 260 | | |
257 | 261 | | |
| |||
0 commit comments