Demo: Agent using Session Notes to remember context.
()
| 75 | |
| 76 | |
| 77 | async 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 | |
| 108 | IMPORTANT - Session Note Management: |
| 109 | You 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 | |
| 113 | Guidelines: |
| 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(), |
no test coverage detected