8000 Escape episode content when returning episode context as string by edwinyyyu · Pull Request #660 · MemMachine/MemMachine · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@edwinyyyu
Copy link
Contributor
@edwinyyyu edwinyyyu commented Dec 2, 2025

Purpose of the change

Appears to help the LLM when there are newlines in the episode context.

Description

Escape episode content in DeclarativeMemory.string_from_episode_context.
Increases LongMemEval score by >1% in one run when using gpt-4.1-mini.

Use json.dumps() because it is a simple solution that always uses double-quotes. repr() may be more semantically natural but quotes inconsistently.

Implement similar changes in EpisodicMemory.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g., code style improvements, linting)
  • Documentation update
  • Project Maintenance (updates to build scripts, CI, etc., that do not affect the main project)
  • Security (improves security without changing functionality)

How Has This Been Tested?

Manually tested with LongMemEval dataset. Tested once for LoCoMo regression. Does not appear to harm LoCoMo scores appreciably.

  • Unit Test
  • Integration Test
  • End-to-end Test
  • Test Script (please provide)
  • Manual verification (list step-by-step instructions)

Checklist

  • I have signed the commit(s) within this pull request
  • My code follows the style guidelines of this project (See STYLE_GUIDE.md)
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • Confirmed all checks passed
  • Contributor has signed the commit(s)
  • Reviewed the code
  • Run, Tested, and Verified the change(s) work as expected

@edwinyyyu edwinyyyu requested a review from malatewang December 2, 2025 00:20
@edwinyyyu edwinyyyu marked this pull request as draft December 3, 2025 19:17
@edwinyyyu edwinyyyu marked this pull request as ready for review December 3, 2025 21:41
Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
@edwinyyyu edwinyyyu force-pushed the escape_string_from_episode_context branch from fee7b64 to 199cb47 Compare December 5, 2025 22:23
@edwinyyyu edwinyyyu merged commit c590b23 into MemMachine:main Dec 5, 2025
33 checks passed
dxu104 pushed a commit to dxu104/MemMachine that referenced this pull request Dec 5, 2025
…achine#660)

* Escape episode content when returning episode context as string

Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>

* Improve EpisodicMemory context formatting

Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>

---------

Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
o-love pushed a commit that referenced this pull request Jan 23, 2026
* Escape episode content when returning episode context as string

Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>

* Improve EpisodicMemory context formatting

Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>

---------

Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
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

0