Skip to content

Issue #1055: Add minimal frontmatter parser for memory files#1119

Open
Meh10t wants to merge 12 commits intooraios:mainfrom
Meh10t:issue-1055-frontmatter
Open

Issue #1055: Add minimal frontmatter parser for memory files#1119
Meh10t wants to merge 12 commits intooraios:mainfrom
Meh10t:issue-1055-frontmatter

Conversation

@Meh10t
Copy link
Copy Markdown

@Meh10t Meh10t commented Mar 2, 2026

This PR starts work on issue #1055.

It introduces a minimal frontmatter parser for memory files, supporting arbitrary YAML-like fields.

Currently supported:

  • Optional YAML-like frontmatter block at the top of a memory file
  • Supports arbitrary frontmatter fields (no restriction to specific keys)
  • Returns both the parsed frontmatter and the remaining body content

Example supported format:


summary: Some short description

This is the memory content...

This is the first step towards supporting opt-in frontmatter tools (MemoryAddFrontmatterTool and MemoryGetFrontmatterTool).

Next steps:

  • Integrate frontmatter stripping in memory loading
  • Implement optional frontmatter tools
  • Extend list_memories behavior when frontmatter tools are enabled

@MischaPanch
Copy link
Copy Markdown
Contributor

This is a draft, right?

@Meh10t
Copy link
Copy Markdown
Author

Meh10t commented Mar 3, 2026

This is a draft, right?

Yes, this is a draft.

This PR only introduces the minimal frontmatter parser as the first step for issue #1055.
The next steps will integrate it into memory loading and implement the optional frontmatter tools.

@MischaPanch
Copy link
Copy Markdown
Contributor

Pls keep in mind our specification. In particular, any kind of frontmatter is allowed. So

Only the summary field is supported for now

Is not correct

@MischaPanch MischaPanch marked this pull request as draft March 4, 2026 09:19
@Meh10t
Copy link
Copy Markdown
Author

Meh10t commented Mar 4, 2026

Pls keep in mind our specification. In particular, any kind of frontmatter is allowed. So

Only the summary field is supported for now

Is not correct

Thanks for the clarification!

I updated the parser so it now accepts any frontmatter key/value pairs instead of restricting it to "summary".

Let me know if this aligns better with the specification.

from typing import Tuple, Dict


def parse_frontmatter(content: str) -> Tuple[Dict[str, str], str]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serena is an object-oriented codebase. Please consistently use OOP principles.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serena is an object-oriented codebase. Please consistently use OOP principles.

Thanks for the feedback! I refactored the frontmatter parsing into an OOP-style FrontmatterParser while keeping parse_frontmatter as a backward-compatible wrapper.

@Meh10t Meh10t force-pushed the issue-1055-frontmatter branch from 634715b to 1c3ac4f Compare March 5, 2026 00:34
@Meh10t Meh10t marked this pull request as ready for review March 10, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants