Record a session note. Args: content: The information to record category: Category/tag for this note Returns: ToolResult with success status
(self, content: str, category: str = "general")
| 89 | self.memory_file.write_text(json.dumps(notes, indent=2, ensure_ascii=False)) |
| 90 | |
| 91 | async def execute(self, content: str, category: str = "general") -> ToolResult: |
| 92 | """Record a session note. |
| 93 | |
| 94 | Args: |
| 95 | content: The information to record |
| 96 | category: Category/tag for this note |
| 97 | |
| 98 | Returns: |
| 99 | ToolResult with success status |
| 100 | """ |
| 101 | try: |
| 102 | # Load existing notes |
| 103 | notes = self._load_from_file() |
| 104 | |
| 105 | # Add new note with timestamp |
| 106 | note = { |
| 107 | "timestamp": datetime.now().isoformat(), |
| 108 | "category": category, |
| 109 | "content": content, |
| 110 | } |
| 111 | notes.append(note) |
| 112 | |
| 113 | # Save back to file |
| 114 | self._save_to_file(notes) |
| 115 | |
| 116 | return ToolResult( |
| 117 | success=True, |
| 118 | content=f"Recorded note: {content} (category: {category})", |
| 119 | ) |
| 120 | except Exception as e: |
| 121 | return ToolResult( |
| 122 | success=False, |
| 123 | content="", |
| 124 | error=f"Failed to record note: {str(e)}", |
| 125 | ) |
| 126 | |
| 127 | |
| 128 | class RecallNoteTool(Tool): |