Repository navigation
fix(config): let semantic memory be disabled with enabled: false alone - #1651
Conversation
| ) | ||
| return missing | ||
|
|
||
| def auto_disable_when_incomplete(self) -> list[str]: |
There was a problem hiding this comment.
The caller does not use the return data. It should be enough to log a message.
There was a problem hiding this comment.
The validator does discard it, but Configuration.auto_disable_semantic_memory uses the returned names — they become the auto-disabled: missing required fields: config_database text in the config API's response, so someone disabling semantic memory through the API is told which field is missing. That came out of an earlier review round asking for the reason to name a field.
Happy to drop it if you'd rather the API just reported that it was disabled.
|
When semantic memory is disabled, the memmachine needs to handle the case when processing read/write request |
|
Good catch — fixed in 3692ae7 and fcdb516. Two things were reaching semantic memory without checking whether it was enabled:
Both now skip semantic memory when it's off, the same way startup, shutdown and session deletion already did. What I didn't touch: a request that explicitly names semantic memory on a disabled server. |
Turning semantic memory off required more than `enabled: false`: the `semantic_memory` section had to be present and `config_database` had to name a database that would never be used, or the configuration failed to load. - `SemanticMemoryConf.config_database` is optional; a missing value now auto-disables semantic memory the same way a missing storage, LLM, or embedder does, and is named in the warning. - `Configuration.semantic_memory` defaults to a disabled section, so the section can be omitted entirely. - `SemanticResourceManager.get_semantic_config_storage` raises `ResourceNotReadyError` when no config database is set, matching the storage getter, instead of passing `None` to the SQL engine lookup. Fixes #1633 Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Marvin Yu <[email protected]>
…null section Follow-ups from review of the #1633 fix: - The runtime config API assigns SemanticMemoryConf fields in place, so an enable request on a config with no config_database (now a legal state) could persist enabled=True and make the next lazy semantic-service build fail. The completeness check is now a public method the API re-runs after every semantic update; a request that leaves the config incomplete is auto-disabled and says so in the change summary. - A bare `semantic_memory:` key (YAML null) now reads as a disabled section, matching the omitted-section behaviour. - The config-storage getter refuses an empty config_database the same way the validator does, not only None. - `enabled` field description and the two doc sites that marked `config_database` required (configuration.mdx, retrieval_agent README) updated to the new contract. - Round-trip test now pins that a complete-but-disabled section keeps `enabled: false` across save and reload. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Marvin Yu <[email protected]>
Second review round on the #1633 fix: - The API re-check covered only the required-fields guard; the sibling OpenAI-credential guard (`Configuration._maybe_disable_semantic_memory`) was still bypassed, so an enable request against an embedder with an empty key and no base_url could persist enabled=True. A new `Configuration.auto_disable_semantic_memory()` runs both guards and returns the reason; both API entry points call it and report the reason in the change summary, naming the missing fields. - `auto_disable_when_incomplete()` returns the missing field names; a new `missing_required_fields()` computes them. - `semantic_memory: {}` is treated like a null or omitted section (disabled, no warning). - `get_semantic_storage` refuses an empty database id the same way the config-storage getter does. - Docs: the `llm_model`, `embedding_model`, and `database` rows are described the same way as `config_database` (required only when semantic memory is enabled). - Tests: the API re-validation tests load the real sample Configuration; both disabled-section shapes are pinned through the YAML round trip; the null/empty-section test asserts no auto-disable warning. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Marvin Yu <[email protected]>
Requests default target_memories to every memory type, so add/search/list dispatched into semantic memory on the type list alone, without consulting semantic_memory.enabled. With the section disabled its required fields are legally unset, so the dispatch reached get_semantic_config_storage and raised ResourceNotReadyError; no route handles it, so a first POST /memories after disabling semantic memory returned an unhandled 500. Route the three dispatch sites through _semantic_memory_targeted, which conjoins the enabled flag, matching what the startup, shutdown, and session-deletion paths already do. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Marvin Yu <[email protected]>
…sabled delete_episodes resolved the semantic service before building any of its work, so with semantic memory disabled the call raised ResourceNotReadyError and never reached episode_storage.delete_episodes. POST /memories/episodic/ delete, which names no semantic memory, returned a 500 and left the episodes in place. Resolve the semantic service only when semantic memory is enabled, and pin both directions. Also rename the dispatch predicate to _should_dispatch_to_semantic_memory, since the call sites gave no sign that it consults configuration as well as its argument, and drop its per-call log so it stays a pure predicate. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Marvin Yu <[email protected]>
aad98ec to
305a0e1
Compare
Purpose of the change
Let semantic memory be turned off with
enabled: falsealone, or by omitting thesemantic_memorysection. Today the configuration refuses to load unless the section is present andconfig_databasenames a database that will never be used.Description
SemanticMemoryConf.config_databasewas declared required (Field(...)) regardless ofenabled, andConfiguration.semantic_memoryhad no default, so an operator disabling semantic memory still had to write a semantic section and point it at a config database.This change:
config_databaseoptional and folds a missing value into the existing auto-disable validator, so a config that setsenabled: truewithout it is auto-disabled with a warning naming the missing fields, the same way a missing storage, LLM, or embedder already is;Configuration.semantic_memorya default of a disabled section, and treats a null or emptysemantic_memory:key the same way, so the section can be omitted;SemanticResourceManager.get_semantic_config_storageraiseResourceNotReadyErrorwhen no config database is set, matching whatget_semantic_storagealready does fordatabase;config_databasenow optional an enable request could otherwise persistenabled: trueon a config the server cannot build. An update that leaves the config incomplete is auto-disabled and the change summary says why.Configs that set
config_databasetoday are unaffected. The runtime request paths that ignoresemantic_memory.enabled(#1600, #1601) and project deletion with semantic memory disabled (#1575) are separate issues and are not touched here.Fixes/Closes
Fixes #1633
Type of change
How Has This Been Tested?
New tests cover:
SemanticMemoryConf(enabled=False)with no config database; auto-disable whenconfig_databaseis missing; the sample config with the section removed, null, empty, and{enabled: false}; both disabled shapes round-tripping throughto_yaml(); the config-storage getter refusing an unset database without touching the SQL engine; and the config API auto-disabling an enable request that lacksconfig_databaseor whose embedder has empty OpenAI credentials.Each guard was mutation-checked: reverting the validator change, the section default, the null/empty mapping, the getter guard, or either API re-check fails exactly the test that names it.
Test Results:
uv run pytest packages/server/server_tests— 1806 passed (the twoinstallation/test_install_in_windows*failures reproduce onmainon this machine and are unrelated);packages/client/client_tests255 passed;ruff check/ruff format --checkclean;ty check packagesunchanged frommain.Checklist
Screenshots/Gifs
N/A
Further comments
The same declarations exist on
speedkick, where #1580 made semantic memory disabled by default, so this fix is worth carrying there too; the diff is confined to the config model, the two getters, and the config service.🤖 Generated with Claude Code