Recall session notes. Args: category: Optional category filter Returns: ToolResult with notes content
(self, category: str = None)
| 161 | } |
| 162 | |
| 163 | async def execute(self, category: str = None) -> ToolResult: |
| 164 | """Recall session notes. |
| 165 | |
| 166 | Args: |
| 167 | category: Optional category filter |
| 168 | |
| 169 | Returns: |
| 170 | ToolResult with notes content |
| 171 | """ |
| 172 | try: |
| 173 | if not self.memory_file.exists(): |
| 174 | return ToolResult( |
| 175 | success=True, |
| 176 | content="No notes recorded yet.", |
| 177 | ) |
| 178 | |
| 179 | notes = json.loads(self.memory_file.read_text()) |
| 180 | |
| 181 | if not notes: |
| 182 | return ToolResult( |
| 183 | success=True, |
| 184 | content="No notes recorded yet.", |
| 185 | ) |
| 186 | |
| 187 | # Filter by category if specified |
| 188 | if category: |
| 189 | notes = [n for n in notes if n.get("category") == category] |
| 190 | if not notes: |
| 191 | return ToolResult( |
| 192 | success=True, |
| 193 | content=f"No notes found in category: {category}", |
| 194 | ) |
| 195 | |
| 196 | # Format notes for display |
| 197 | formatted = [] |
| 198 | for idx, note in enumerate(notes, 1): |
| 199 | timestamp = note.get("timestamp", "unknown time") |
| 200 | cat = note.get("category", "general") |
| 201 | content = note.get("content", "") |
| 202 | formatted.append(f"{idx}. [{cat}] {content}\n (recorded at {timestamp})") |
| 203 | |
| 204 | result = "Recorded Notes:\n" + "\n".join(formatted) |
| 205 | |
| 206 | return ToolResult(success=True, content=result) |
| 207 | |
| 208 | except Exception as e: |
| 209 | return ToolResult( |
| 210 | success=False, |
| 211 | content="", |
| 212 | error=f"Failed to recall notes: {str(e)}", |
| 213 | ) |