> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# To-Do Management

> Automatic todo tracking and completion enforcement

## Usage

DeepAgent provides automatic todo tracking. Todos follow a strict lifecycle: `pending` → `in_progress` → `completed`.

## Todo Lifecycle

1. **Created** as `"pending"` or `"in_progress"`
2. **Marked** `"in_progress"` before starting work
3. **Marked** `"completed"` immediately after finishing
4. **Agent continues** until ALL todos are `"completed"`

## Example

```python theme={null}
import asyncio
from upsonic.agent.deepagent import DeepAgent
from upsonic import Task

async def main():
    agent = DeepAgent(model="anthropic/claude-sonnet-4-5")
    
    task = Task(description="""
    Research Python frameworks, compare their features, and write a comparison report.
    
    Execute all tasks and ensure everything is completed.
    Save findings to /research/frameworks.txt and report to /reports/comparison.txt
    """)
    
    result = await agent.do_async(task)
    
    # Get current todos
    todos = agent.get_current_plan()
    
    print(f"\nTodo Status:")
    completed = sum(1 for t in todos if t['status'] == 'completed')
    total = len(todos)
    print(f"  Completed: {completed}/{total}")
    
    for todo in todos:
        status_icon = "✅" if todo['status'] == 'completed' else "⏳"
        print(f"  {status_icon} [{todo['status']}] {todo['content']}")

asyncio.run(main())
```

## Programmatic Access

```python theme={null}
import asyncio
from upsonic.agent.deepagent import DeepAgent
from upsonic import Task

async def main():
    agent = DeepAgent(model="anthropic/claude-sonnet-4-5", tool_call_limit=50)
    
    task = Task(description="Create a comprehensive plan to build a personal productivity web application with features for task management, calendar integration, and progress tracking. Break down the work into actionable todos and execute each step while tracking your progress.")
    result = await agent.do_async(task)
    
    # Get current todos
    todos = agent.get_current_plan()
    
    # Access todo details
    for todo in todos:
        print(f"ID: {todo['id']}")
        print(f"Content: {todo['content']}")
        print(f"Status: {todo['status']}")
        print()

asyncio.run(main())
```

## Key Points

* Todos are automatically tracked per task
* Agent updates todos after each completion
* Use `get_current_plan()` to monitor progress
* All todos must be completed before task finishes
