MCPcopy Index your code
hub / github.com/MiniMax-AI/Mini-Agent / demo_agent_with_notes

Function demo_agent_with_notes

examples/03_session_notes.py:77–228  ·  view source on GitHub ↗

Demo: Agent using Session Notes to remember context.

()

Source from the content-addressed store, hash-verified

75
76
77async def demo_agent_with_notes():
78 """Demo: Agent using Session Notes to remember context."""
79 print("\n" + "=" * 60)
80 print("Demo 2: Agent with Session Memory")
81 print("=" * 60)
82
83 # Load configuration
84 config_path = Path("mini_agent/config/config.yaml")
85 if not config_path.exists():
86 print("❌ config.yaml not found")
87 return
88
89 config = Config.from_yaml(config_path)
90
91 if not config.llm.api_key or config.llm.api_key.startswith("YOUR_"):
92 print("❌ API key not configured")
93 return
94
95 with tempfile.TemporaryDirectory() as workspace_dir:
96 print(f"📁 Workspace: {workspace_dir}\n")
97
98 # Load system prompt (Agent will auto-inject workspace info)
99 system_prompt_path = Path("mini_agent/config/system_prompt.md")
100 if system_prompt_path.exists():
101 system_prompt = system_prompt_path.read_text(encoding="utf-8")
102 else:
103 system_prompt = "You are a helpful AI assistant."
104
105 # Add Session Note instructions
106 note_instructions = """
107
108IMPORTANT - Session Note Management:
109You have access to record_note and recall_notes tools. Use them to:
110- record_note: Save important facts, preferences, decisions that should persist
111- recall_notes: Retrieve previously saved notes
112
113Guidelines:
114- Proactively record key information during conversations
115- Recall notes at the start to restore context
116- Categories: user_info, user_preference, project_info, decision, etc.
117"""
118 system_prompt += note_instructions
119
120 # Initialize LLM
121 llm_client = LLMClient(
122 api_key=config.llm.api_key,
123 api_base=config.llm.api_base,
124 model=config.llm.model,
125 )
126
127 # Memory file
128 memory_file = Path(workspace_dir) / ".agent_memory.json"
129
130 # Tools including Session Note tools
131 tools = [
132 ReadTool(workspace_dir=workspace_dir),
133 WriteTool(workspace_dir=workspace_dir),
134 BashTool(),

Callers 1

mainFunction · 0.85

Calls 10

add_user_messageMethod · 0.95
runMethod · 0.95
LLMClientClass · 0.90
ReadToolClass · 0.90
WriteToolClass · 0.90
BashToolClass · 0.90
SessionNoteToolClass · 0.90
RecallNoteToolClass · 0.90
AgentClass · 0.90
from_yamlMethod · 0.80

Tested by

no test coverage detected