mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
feat: add no-update sentinel handling to save_memory function and corresponding unit tests
This commit is contained in:
parent
132e7b3c44
commit
8c9be9796a
2 changed files with 64 additions and 0 deletions
|
|
@ -29,6 +29,15 @@ from app.services.memory.validation import (
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_NO_UPDATE_SENTINELS = frozenset(
|
||||
{
|
||||
"NO_UPDATE",
|
||||
"NO UPDATE",
|
||||
"NO_CHANGE",
|
||||
"NO CHANGE",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class MemoryScope(StrEnum):
|
||||
USER = "user"
|
||||
|
|
@ -149,6 +158,13 @@ async def save_memory(
|
|||
notice: str | None = None
|
||||
warnings: list[str] = []
|
||||
|
||||
if next_content.upper() in _NO_UPDATE_SENTINELS:
|
||||
return SaveResult(
|
||||
status="no_op",
|
||||
message="No memory update requested.",
|
||||
memory_md=old_memory,
|
||||
)
|
||||
|
||||
if len(next_content) > MEMORY_HARD_LIMIT and llm is not None:
|
||||
rewritten = await forced_rewrite(next_content, llm)
|
||||
if rewritten is not None and len(rewritten) < len(next_content):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue