State is written to disk, surviving compression
"State that survives compression — because it's outside the conversation."
What is the difference between TodoWrite and Task?
TodoManager of s03 can also list tasks - but it is stored in memory. As soon as auto_compact mentioned in s06 is triggered, messages[] is replaced by summary, and the status of TodoManager is disappeared (because it is in-memory).
The Task of s07 is different: each task is a .tasks/task_42.json file. Whether the context is compressed, the process is restarted, or the agent is replaced - as long as the disk file still exists, the task still exists.
# .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 "owner": "" }
Selection rules: Usetodofor temporary to-dos (forget about it once you finish it); usetaskfor persistent tasks (retained across sessions and dependent).
blockedBy · Dependency graph temper
blockedBy is a list of task ids - these must be completed before the current task is "executable".
The implementation of s07 has a neat detail: When a task is completed, it will automatically remove itself from the blockedBy list of all other tasks.
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)
In this way, the agent does not need to maintain a separate "what tasks are unblocked" table - as long as it traverses .tasks/, the one found status=="pending" and not blockedBy is now executable.
Dependency graph interaction
The widget below gives you a dependency graph of 5 tasks. Click "complete" to see blockedBy automatically updated and which tasks become "executable" (highlighted in green).
Can it still survive after being compressed?
s06 mentioned that auto_compact will replace messages[] with a summary. But the task is not affected because it is on disk. Test it: Let the agent do 5 tasks. After compressing the conversation, it scans .tasks/ and it can continue in the same place.