From 94fc05b6e530453427a5045a0ffa53f47dc430c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 12:00:54 -0800 Subject: [PATCH] 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 Co-authored-by: Sarah Wooders --- letta/constants.py | 2 +- letta/schemas/memory.py | 2 -- letta/services/memory_repo/block_markdown.py | 12 ++++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/letta/constants.py b/letta/constants.py index e36b0b32..0abe94a8 100644 --- a/letta/constants.py +++ b/letta/constants.py @@ -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 diff --git a/letta/schemas/memory.py b/letta/schemas/memory.py index 3c17f557..ce80fb33 100644 --- a/letta/schemas/memory.py +++ b/letta/schemas/memory.py @@ -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") diff --git a/letta/services/memory_repo/block_markdown.py b/letta/services/memory_repo/block_markdown.py index 3c9d3e3a..dfb70afe 100644 --- a/letta/services/memory_repo/block_markdown.py +++ b/letta/services/memory_repo/block_markdown.py @@ -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"):