Tool for recording and recalling session notes. The agent can use this tool to: - Record important facts, decisions, or context during sessions - Recall information from previous sessions - Build up knowledge over time Example usage by agent: - record_note("User prefers con
| 15 | |
| 16 | |
| 17 | class SessionNoteTool(Tool): |
| 18 | """Tool for recording and recalling session notes. |
| 19 | |
| 20 | The agent can use this tool to: |
| 21 | - Record important facts, decisions, or context during sessions |
| 22 | - Recall information from previous sessions |
| 23 | - Build up knowledge over time |
| 24 | |
| 25 | Example usage by agent: |
| 26 | - record_note("User prefers concise responses") |
| 27 | - record_note("Project uses Python 3.12 and async/await") |
| 28 | - recall_notes() -> retrieves all recorded notes |
| 29 | """ |
| 30 | |
| 31 | def __init__(self, memory_file: str = "./workspace/.agent_memory.json"): |
| 32 | """Initialize session note tool. |
| 33 | |
| 34 | Args: |
| 35 | memory_file: Path to the note storage file |
| 36 | """ |
| 37 | self.memory_file = Path(memory_file) |
| 38 | # Lazy loading: file and directory are only created when first note is recorded |
| 39 | |
| 40 | @property |
| 41 | def name(self) -> str: |
| 42 | return "record_note" |
| 43 | |
| 44 | @property |
| 45 | def description(self) -> str: |
| 46 | return ( |
| 47 | "Record important information as session notes for future reference. " |
| 48 | "Use this to record key facts, user preferences, decisions, or context " |
| 49 | "that should be recalled later in the agent execution chain. Each note is timestamped." |
| 50 | ) |
| 51 | |
| 52 | @property |
| 53 | def parameters(self) -> dict[str, Any]: |
| 54 | return { |
| 55 | "type": "object", |
| 56 | "properties": { |
| 57 | "content": { |
| 58 | "type": "string", |
| 59 | "description": "The information to record as a note. Be concise but specific.", |
| 60 | }, |
| 61 | "category": { |
| 62 | "type": "string", |
| 63 | "description": "Optional category/tag for this note (e.g., 'user_preference', 'project_info', 'decision')", |
| 64 | }, |
| 65 | }, |
| 66 | "required": ["content"], |
| 67 | } |
| 68 | |
| 69 | def _load_from_file(self) -> list: |
| 70 | """Load notes from file. |
| 71 | |
| 72 | Returns empty list if file doesn't exist (lazy loading). |
| 73 | """ |
| 74 | if not self.memory_file.exists(): |
no outgoing calls