State written to disk, survives compression
"State that survives compression - because it's outside the conversation."
What is the difference between TodoWrite and Task?
s03's TodoManager can also list tasks - but it stores them in memory. When s06's auto_compact fires and replaces messages[] with a summary, the TodoManager state disappears with it (because it's in-memory).
s07's Task is different: each task is a .tasks/task_42.json file. Context compacted, process restarted, agent swapped out - as long as the file is on disk, the task survives.
# .tasks/task_12.json { "id": 12, "subject": "Refactor auth middleware", "description": "Extract JWT logic to shared module", "status": "pending", "blockedBy": [8, 11], # must complete #8 and #11 first "owner": "" }
Rule of thumb: Usetodofor ephemeral tasks (forget after this session). Usetaskfor persistent work (cross-session, with dependencies).
blockedBy: the dependency graph
blockedBy is a list of task IDs - the current task can't execute until all of them are completed.
s07's implementation has an elegant detail: when a task is completed, it automatically removes itself from all other tasks' blockedBy lists.
def _clear_dependency(self, completed_id: int): # Scan every task, remove completed_id from their blockedBy for f in self.dir.glob("task_*.json"): task = json.loads(f.read_text()) if completed_id in task.get("blockedBy", []): task["blockedBy"].remove(completed_id) self._save(task)
The agent never needs a separate "which tasks just unblocked" table. Just scan .tasks/, find entries where status=="pending" and not blockedBy - those are the ready tasks.
Dependency graph interaction
The widget below gives you a 5-task dependency graph. Click "complete" and watch blockedBy update automatically, turning some tasks green (ready to execute).
Does it survive compression?
s06 showed that auto_compact replaces messages[] with a single summary. But tasks are unaffected - they're on disk. Test it: have the agent create 5 tasks, compact the conversation, then scan .tasks/ to resume.