feat: remove limit from git-base memory frontmatter and increase default to 100k (#9537)
- Remove `limit` from YAML frontmatter in `serialize_block()` and `merge_frontmatter_with_body()` (deprecated for git-base memory) - Remove `limit` from `_render_memory_blocks_git()` in-context rendering - Existing frontmatter with `limit` is automatically cleaned up on next write - Parsing still accepts `limit` from frontmatter for backward compatibility - Increase `CORE_MEMORY_BLOCK_CHAR_LIMIT` from 20,000 to 100,000 - Update integration tests to assert `limit` is not in frontmatter Fixes #9536 Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com> Co-authored-by: Sarah Wooders <sarahwooders@users.noreply.github.com> Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
This commit is contained in:
committed by
Caren Thomas
parent
0020f4b866
commit
94fc05b6e5
@@ -419,7 +419,7 @@ MAX_ERROR_MESSAGE_CHAR_LIMIT = 1000
|
||||
# Default memory limits
|
||||
CORE_MEMORY_PERSONA_CHAR_LIMIT: int = 20000
|
||||
CORE_MEMORY_HUMAN_CHAR_LIMIT: int = 20000
|
||||
CORE_MEMORY_BLOCK_CHAR_LIMIT: int = 20000
|
||||
CORE_MEMORY_BLOCK_CHAR_LIMIT: int = 100000
|
||||
|
||||
# Function return limits
|
||||
FUNCTION_RETURN_CHAR_LIMIT = 50000 # ~300 words
|
||||
|
||||
@@ -226,8 +226,6 @@ class Memory(BaseModel, validate_assignment=True):
|
||||
front_lines = []
|
||||
if block.description:
|
||||
front_lines.append(f"description: {block.description}")
|
||||
if block.limit is not None:
|
||||
front_lines.append(f"limit: {block.limit}")
|
||||
if getattr(block, "read_only", False):
|
||||
front_lines.append("read_only: true")
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
File format:
|
||||
---
|
||||
description: "Who I am and how I approach work"
|
||||
limit: 20000
|
||||
---
|
||||
My name is Memo. I'm a stateful coding assistant...
|
||||
|
||||
- Frontmatter fields are only rendered when they differ from defaults.
|
||||
- ``limit`` is intentionally excluded from frontmatter (deprecated for git-base memory).
|
||||
- Files without frontmatter are treated as value-only (backward compat).
|
||||
"""
|
||||
|
||||
@@ -37,12 +37,12 @@ def serialize_block(
|
||||
This is used for initial file creation. For updates to existing files,
|
||||
prefer `merge_frontmatter_with_body` to preserve user formatting.
|
||||
"""
|
||||
# description and limit are always included in frontmatter.
|
||||
# description is always included in frontmatter.
|
||||
# read_only and metadata are only included when non-default.
|
||||
# limit is intentionally excluded (deprecated for git-base memory).
|
||||
front: Dict[str, Any] = {}
|
||||
|
||||
front["description"] = description
|
||||
front["limit"] = limit if limit is not None else _get_field_default("limit")
|
||||
|
||||
if read_only != _get_field_default("read_only"):
|
||||
front["read_only"] = read_only
|
||||
@@ -111,7 +111,6 @@ def merge_frontmatter_with_body(
|
||||
|
||||
# Desired values
|
||||
desired_description = description
|
||||
desired_limit = limit if limit is not None else _get_field_default("limit")
|
||||
desired_read_only = read_only
|
||||
desired_metadata = metadata if metadata is not None else _get_field_default("metadata")
|
||||
|
||||
@@ -122,8 +121,9 @@ def merge_frontmatter_with_body(
|
||||
parsed["description"] = desired_description
|
||||
changed = True
|
||||
|
||||
if "limit" not in parsed or parsed.get("limit") != desired_limit:
|
||||
parsed["limit"] = desired_limit
|
||||
# Remove limit from frontmatter if it exists (deprecated for git-base memory)
|
||||
if "limit" in parsed:
|
||||
del parsed["limit"]
|
||||
changed = True
|
||||
|
||||
if desired_read_only != _get_field_default("read_only"):
|
||||
|
||||
Reference in New Issue
Block a user