feat(agent): add long-term memory extraction and visualization#412
Open
newcat22 wants to merge 2 commits into
Open
feat(agent): add long-term memory extraction and visualization#412newcat22 wants to merge 2 commits into
newcat22 wants to merge 2 commits into
Conversation
Add LLM-powered memory extraction that compresses agent execution steps into human-readable Markdown documents with problem/conclusion pairs. Supports manual and periodic triggers via factory pattern, context compression when messages exceed 20, and CLI commands for offline extraction from trajectory files.
|
|
Add --memory CLI flag to preload previous session memory into new sessions, session ID tracking in memory files and index.json, memory-list command for viewing session-memory associations, and preloaded_sections that persist across set_task() calls.
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.
Summary
trae-cli memorysubcommand for offline extraction from trajectory JSON files, and--extract-memoryflag onruncommandNew files
trae_agent/utils/long_term_memory.py— Core module: LLM extraction, Markdown rendering (MemoryDocument with to_markdown/from_markdown round-trip), memory message buildertrae_agent/utils/memory_trigger.py— Trigger factory: ManualMemoryTrigger, PeriodicMemoryTrigger, create_memory_trigger() factorytests/utils/test_long_term_memory.py— 22 test cases covering config, triggers, document round-trip, memory injection, and end-to-end extractionModified files
trae_agent/utils/config.py— LongTermMemoryConfig dataclass + YAML parsingtrae_agent/agent/base_agent.py— Memory trigger integration in execute_task(), context compression in _run_llm_step(), inject_memory_into_messages(), extract_memory_now()trae_agent/agent/agent.py— Wire up LongTermMemory creation and set_task()trae_agent/cli.py—memorysubcommand +--extract-memoryflagtrae_agent/utils/cli/cli_console.py— set_memory_doc() base methodtrae_agent/utils/cli/simple_console.py— Memory summary visualization with Rich Panelstrae_config.yaml.example— long_term_memory config examplesTest plan