peek_context
View parent tasks and previous steps to understand the current task's purpose and maintain context in hierarchical task management systems.
Instructions
Look at parent task and previous sibling without changing focus (understand WHY you're doing current task)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_body | No | Include task body content |
Implementation Reference
- src/handlers.py:175-197 (handler)Main handler function that peeks at parent and immediate context tasks, formats them optionally including body, and returns as dict.async def handle_peek_context(self, include_body: bool = False) -> Dict[str, Any]: parent, immediate = self.task_manager.peek_context() def format_task(task: Optional[Task]) -> Optional[Dict[str, Any]]: if not task: return None result = { "id": task.id, "title": task.title, "status": task.status.value, "created_at": task.created_at.isoformat(), } if include_body: result["body"] = task.body if task.completed_at: result["completed_at"] = task.completed_at.isoformat() return result return { "parent_context": format_task(parent), "immediate_context": format_task(immediate), }
- src/handlers.py:330-343 (schema)Tool schema definition including input schema for include_body parameter.Tool( name="peek_context", description="Look at parent task and previous sibling without changing focus (understand WHY you're doing current task)", inputSchema={ "type": "object", "properties": { "include_body": { "type": "boolean", "description": "Include task body content", "default": False, } }, }, ),
- src/server.py:67-69 (registration)Registration of the peek_context tool in the server handler map, mapping to the handlers.handle_peek_context method."peek_context": lambda: handlers.handle_peek_context( arguments.get("include_body", False) ),
- src/task_manager.py:359-379 (helper)Helper method in TaskManager that returns the parent task and immediate previous context (sibling or previous main task).def peek_context(self) -> Tuple[Optional[Task], Optional[Task]]: current = self.current_task if not current: return None, None if isinstance(current, SubTask): last_main_task = self.global_tasks[-1] siblings = self.get_siblings_to_left() immediate_context = siblings[-1] if siblings else None return last_main_task, immediate_context else: if len(self.global_tasks) > 1: prev_main_task = self.global_tasks[-2] prev_immediate_context: Task = ( prev_main_task.sub_tasks[-1] if prev_main_task.sub_tasks else prev_main_task ) return prev_main_task, prev_immediate_context return None, None