remove_task
Removes a task from the hierarchical structure, including all its subtasks if it’s a parent task. The task remains in the completed_tasks history if completed. Use task IDs from get_big_picture or get_stack_overview for removal.
Instructions
Remove a task from the structure (cleanup your workspace). The task remains in completed_tasks history if it was completed. Can remove any task (completed or not). Removing a parent task removes all its subtasks. Use get_big_picture or get_stack_overview to see task IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | The ID of the task to remove from the structure |
Implementation Reference
- src/handlers.py:226-232 (handler)The tool handler function that receives the tool call, extracts task_id, calls task_manager.remove_task, and returns the result or error.async def handle_remove_task(self, task_id: str) -> Dict[str, Any]: try: result = self.task_manager.remove_task(task_id) return result except ValueError as e: return {"error": str(e)}
- src/task_manager.py:427-467 (helper)Core implementation that locates the task by ID in main_tasks or subtasks, removes it from the structure, clears manual focus if needed, and returns success details. Tasks in completed_tasks history are preserved.def remove_task(self, task_id: str) -> Dict[str, Any]: """Remove a task from the structure (but keep in completed_tasks if it was completed).""" # Find the task in the structure removed_task: Optional[Task] = None # Check main tasks for i, main_task in enumerate(self.global_tasks): if main_task.id == task_id: removed_task = main_task self.global_tasks.pop(i) # If this was the current task, clear manual focus if removed_task == self._manual_current_task: self._manual_current_task = None return { "success": True, "message": f"Removed task: {removed_task.title}", "task_id": task_id, "was_completed": removed_task.status == TaskStatus.COMPLETED, } # Check subtasks for j, sub_task in enumerate(main_task.sub_tasks): if sub_task.id == task_id: removed_task = sub_task main_task.sub_tasks.pop(j) # If this was the current task, clear manual focus if removed_task == self._manual_current_task: self._manual_current_task = None return { "success": True, "message": f"Removed subtask: {removed_task.title}", "task_id": task_id, "was_completed": removed_task.status == TaskStatus.COMPLETED, } raise ValueError(f"Task with ID '{task_id}' not found in structure")
- src/handlers.py:372-385 (schema)Tool schema definition including name, description, and input schema requiring 'task_id' string.Tool( name="remove_task", description="Remove a task from the structure (cleanup your workspace). The task remains in completed_tasks history if it was completed. Can remove any task (completed or not). Removing a parent task removes all its subtasks. Use get_big_picture or get_stack_overview to see task IDs.", inputSchema={ "type": "object", "properties": { "task_id": { "type": "string", "description": "The ID of the task to remove from the structure", } }, "required": ["task_id"], }, ),
- src/server.py:48-75 (registration)Registration of the remove_task tool in the handler_map dictionary within the @server.call_tool() function, mapping the tool name to a lambda that calls the handler with task_id argument.handler_map = { "create_new_task": lambda: handlers.handle_create_new_task( arguments["title"], arguments["body"] ), "extend_current_task": lambda: handlers.handle_extend_current_task( arguments["title"], arguments["body"] ), "get_current_task": handlers.handle_get_current_task, "get_big_picture": lambda: handlers.handle_get_big_picture( arguments.get("format", "text") ), "complete_current_task": handlers.handle_complete_current_task, "get_completed_tasks": lambda: handlers.handle_get_completed_tasks( arguments.get("order", "chronological") ), "update_current_task": lambda: handlers.handle_update_current_task( arguments["body"] ), "get_stack_overview": handlers.handle_get_stack_overview, "peek_context": lambda: handlers.handle_peek_context( arguments.get("include_body", False) ), "list_siblings": lambda: handlers.handle_list_siblings( arguments.get("include_body", False) ), "switch_focus": lambda: handlers.handle_switch_focus(arguments["task_id"]), "remove_task": lambda: handlers.handle_remove_task(arguments["task_id"]), }