Repository navigation
fix(memory): extend the frontmatter read to the closing fence when the byte cap cuts it off - #3617
Merged
Merged
Conversation
…e byte cap cuts it off
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope Version
2.0.12dev (main @
4acacb9)Description
The agentic-memory indexer reads only a byte-capped prefix of each memory file before parsing frontmatter (
retrieval_max_tokens_per_frontmatterdefaults to 256 tokens = 1024 bytes). The parsing regex requires a closing fence, so when the frontmatter block itself outgrows the cap the fence sits outside the prefix, the regex cannot match, and the file'sdescription/typemetadata are all silently dropped from the memory index (#3616 has the repro). #3345 already fixed the sibling case where only the trailing newline falls outside the prefix.Changes — extract the prefix computation into
_frontmatter_snippetand extend the read window to the closing fence when one exists beyond the cap:The fence sits near the top of the file by definition, so the extension is bounded;
rawis already fully in memory (read_file), so nothing extra is read. Behavior matrix:{}How to test
Three regression cases added to the existing
FrontmatterParseTestintests/middleware_filesystem_memory_test.py: the over-cap file now yieldsdescription+typethrough the extended window; the unclosed and within-cap shapes are pinned to their current behavior.python -m pytest tests/middleware_filesystem_memory_test.py # 13 passed.Fixes #3616
Checklist