Demo: Direct usage of Session Note tools.
()
| 19 | |
| 20 | |
| 21 | async def demo_direct_note_usage(): |
| 22 | """Demo: Direct usage of Session Note tools.""" |
| 23 | print("\n" + "=" * 60) |
| 24 | print("Demo 1: Direct Session Note Tool Usage") |
| 25 | print("=" * 60) |
| 26 | |
| 27 | with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".json") as f: |
| 28 | note_file = f.name |
| 29 | |
| 30 | try: |
| 31 | # Create tools |
| 32 | record_tool = SessionNoteTool(memory_file=note_file) |
| 33 | recall_tool = RecallNoteTool(memory_file=note_file) |
| 34 | |
| 35 | # Record some notes |
| 36 | print("\n📝 Recording notes...") |
| 37 | |
| 38 | result = await record_tool.execute( |
| 39 | content="User is a Python developer working on agent systems", |
| 40 | category="user_info", |
| 41 | ) |
| 42 | print(f" ✓ {result.content}") |
| 43 | |
| 44 | result = await record_tool.execute( |
| 45 | content="Project name: mini-agent, Tech: Python 3.12 + async", |
| 46 | category="project_info", |
| 47 | ) |
| 48 | print(f" ✓ {result.content}") |
| 49 | |
| 50 | result = await record_tool.execute( |
| 51 | content="User prefers concise, well-documented code", |
| 52 | category="user_preference", |
| 53 | ) |
| 54 | print(f" ✓ {result.content}") |
| 55 | |
| 56 | # Recall all notes |
| 57 | print("\n🔍 Recalling all notes...") |
| 58 | result = await recall_tool.execute() |
| 59 | print(result.content) |
| 60 | |
| 61 | # Recall filtered notes |
| 62 | print("\n🔍 Recalling user preferences only...") |
| 63 | result = await recall_tool.execute(category="user_preference") |
| 64 | print(result.content) |
| 65 | |
| 66 | # Show the memory file |
| 67 | print("\n📄 Memory file content:") |
| 68 | print("=" * 60) |
| 69 | notes = json.loads(Path(note_file).read_text()) |
| 70 | print(json.dumps(notes, indent=2, ensure_ascii=False)) |
| 71 | print("=" * 60) |
| 72 | |
| 73 | finally: |
| 74 | Path(note_file).unlink(missing_ok=True) |
| 75 | |
| 76 | |
| 77 | async def demo_agent_with_notes(): |
no test coverage detected