On TypeScript Agent SDK 0.3.233 and later, or Python Agent SDK 0.2.139 and later, the following tools aren’t available on Opus 4.8, Sonnet 5, Fable 5, Mythos 5, or later versions of those families unless you opt in:
TodoWriteTaskCreateTaskGetTaskUpdateTaskList
TodoWrite only when you set CLAUDE_CODE_ENABLE_TASKS=0.Model availability
On the models that don’t get the task-tracking tools, you see notool_use blocks for them in the message stream unless you opt in. If you point cli_path in Python or pathToClaudeCodeExecutable in TypeScript at your own Claude Code install, you get whichever tools that install provides. To get the same tools as on other models, do one of the following:
- Name one of the tools in the
allowedToolsoption,allowed_toolsin Python - List the tools in the
toolsoption, which restricts the session’s built-in tools to the ones it names. Include the tools you want alongside the other built-in tools you use - Set
CLAUDE_CODE_ENABLE_TODO_TOOLS=1in theenvoption, as the examples on this page do. In TypeScript,envreplaces the subprocess environment, so spread...process.envto keep inherited variables. In Python,envis merged on top of the inherited environment
Todo Lifecycle
Claude moves each todo through a predictable lifecycle:- Created: Claude adds the todo as
pendingwhen it identifies a task - Activated: Claude sets the todo to
in_progresswhen it starts the work - Completed: Claude marks it completed when the task finishes successfully
- Removed: Claude deletes a todo it no longer needs by setting
status: "deleted"in aTaskUpdatecall
When Todos Are Used
In a session that has the task-tracking tools, Claude creates todos for most multi-step work, such as:- Complex multi-step tasks requiring 3 or more distinct actions
- User-provided task lists when multiple items are mentioned
- Non-trivial operations that benefit from progress tracking
- Explicit requests when users ask for todo organization
Examples
Before running these examples, install the Claude Agent SDK by following the quickstart. Each example runs until the agent finishes and yields its final result message. If a session reaches its turn limit first, that result message has theerror_max_turns subtype. Check subtype to detect that ending.
These examples use single-shot query() calls. After yielding an error_max_turns result, query() raises an error that includes Reached maximum number of turns. Each example wraps its loop in a try block to exit cleanly when that happens.
See Handle the result for the result subtypes.
Monitoring Todo Changes
Real-time Progress Display
Migrate to Task tools
The Task tools split the singleTodoWrite call into TaskCreate for each new item and TaskUpdate for each status change, with TaskList and TaskGet available for the model to read back the current list. Your monitoring code still inspects tool_use blocks in the assistant stream, but maintains a map keyed by task ID instead of replacing the whole list on every call.
The assigned task ID is not in the
TaskCreate input. It comes back in the matching tool_result as { task: { id, subject } }, so capture it from the result block to key your map.
The following example shows the minimal change to the Monitoring Todo Changes loop. It leaves CLAUDE_CODE_ENABLE_TASKS unset, because the Task tools are the default, and sets only CLAUDE_CODE_ENABLE_TODO_TOOLS=1, the opt-in for the models that otherwise don’t get the tools. It reads only tool_use inputs and skips capturing IDs from tool_result blocks. To render a complete list, watch for a TaskList tool result in the stream or accumulate TaskCreate results and TaskUpdate inputs into a map.
The streamed tool_use input is the raw shape the model emitted. Claude Code repairs some close-but-incorrect key names before execution, mapping id or task_id to taskId and active_form to activeForm, but that repair is not reflected in the stream. Read TaskUpdate input fields defensively, as the samples below do, rather than assuming the canonical name is always present.