MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / test_session_memory_demo

Function test_session_memory_demo

tests/test_integration.py:123–241  ·  view source on GitHub ↗

Test session memory functionality across multiple agent instances. This is the integration test for session note tool, converted from example_memory.py.

()

Source from the content-addressed store, hash-verified

121
122@pytest.mark.asyncio
123async def test_session_memory_demo():
124 """Test session memory functionality across multiple agent instances.
125
126 This is the integration test for session note tool,
127 converted from example_memory.py.
128 """
129 print("\n" + "=" * 80)
130 print("Integration Test: Session Memory Demo")
131 print("=" * 80)
132
133 # Load config
134 config_path = Path("mini_agent/config/config.yaml")
135 if not config_path.exists():
136 pytest.skip("config.yaml not found")
137
138 config = Config.from_yaml(config_path)
139
140 # Check API key
141 if not config.llm.api_key or config.llm.api_key == "YOUR_MINIMAX_API_KEY_HERE":
142 pytest.skip("API key not configured")
143
144 # Use temporary workspace
145 with tempfile.TemporaryDirectory() as workspace_dir:
146 # Use simplified system prompt for faster testing
147 system_prompt = """You are a helpful AI assistant.
148
149You have record_note and recall_notes tools:
150- record_note: Save important information (use category to organize)
151- recall_notes: Retrieve saved information
152"""
153
154 # Initialize LLM
155 llm_client = LLMClient(
156 api_key=config.llm.api_key,
157 api_base=config.llm.api_base,
158 model=config.llm.model,
159 )
160
161 # Memory file path
162 memory_file = Path(workspace_dir) / ".agent_memory.json"
163
164 # Initialize tools (only Session Note Tools for this test)
165 tools = [
166 SessionNoteTool(memory_file=str(memory_file)),
167 RecallNoteTool(memory_file=str(memory_file)),
168 ]
169
170 print("\n📝 Creating Agent with Session Note tools...")
171 agent = Agent(
172 llm_client=llm_client,
173 system_prompt=system_prompt,
174 tools=tools,
175 max_steps=8, # Reduced from 15
176 workspace_dir=workspace_dir,
177 )
178
179 # Task 1: First conversation - agent should save memories
180 task1 = """

Callers 1

mainFunction · 0.85

Calls 7

add_user_messageMethod · 0.95
runMethod · 0.95
LLMClientClass · 0.90
SessionNoteToolClass · 0.90
RecallNoteToolClass · 0.90
AgentClass · 0.90
from_yamlMethod · 0.80

Tested by

no test coverage detected