A ready-to-run example is available here!
Overview
The TaskToolSet lets a parent agent launch sub-agents that handle complex, multi-step tasks autonomously. Each sub-agent runs synchronously — the parent blocks until the sub-agent finishes and returns its result. Sub-agents can be resumed later using a task ID, preserving their full conversation context. This pattern is useful when:- Delegating specialized work to purpose-built sub-agents
- Breaking a problem into sequential steps handled by different experts
- Maintaining conversational context across multiple interactions with a sub-agent
- Isolating sub-task complexity from the parent agent’s context
How It Works
The agent calls the task tool with a prompt and a sub-agent type. The TaskManager creates (or resumes) a sub-agent conversation, runs it to completion, and returns the result to the parent.Task Lifecycle
- Creation — A fresh sub-agent and conversation are created
- Running — The sub-agent processes the prompt autonomously
- Completion — The final response is extracted and returned
- Persistence — The conversation is saved to disk for potential resumption
- Resumption (optional) — A previously completed task continues with full context
Setting Up the TaskToolSet
Register Custom Sub-Agent Types (Optional)
By default, a"default" general-purpose agent is available. Register custom types for specialized behavior:Add TaskToolSet to the Agent
register_tool() call is needed.Create a Conversation
The
DelegationVisualizer is optional but recommended — it shows the multi-agent conversation flow in the terminal.Tool Parameters
When the parent agent calls the task tool, it provides these parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | str | Yes | The instruction for the sub-agent |
subagent_type | str | No | Which registered agent type to use (default: "default") |
description | str | No | Short label (3-5 words) for display and tracking |
resume | str | No | Task ID from a previous invocation to continue |
max_turns | int | No | Maximum agent iterations before stopping (default: 500) |
Task Observation
The tool returns aTaskObservation containing:
| Field | Description |
|---|---|
task_id | Unique identifier (e.g., task_00000001) — use this for resumption |
subagent | The agent type that handled the task |
status | Final status: succeeded, empty_success, or error |
text | The sub-agent’s response (or error message) |
Resuming Tasks
A key feature of TaskToolSet is the ability to resume a previously completed task. When a task finishes, its conversation is persisted to disk. Passing theresume parameter with the task ID reloads the full conversation history, allowing the sub-agent to continue where it left off.
TaskToolSet vs DelegateTool
| TaskToolSet | DelegateTool | |
|---|---|---|
| Execution | Sequential (blocking) | Parallel (concurrent) |
| Concurrency | One task at a time | Multiple sub-agents simultaneously |
| Resumption | Built-in via resume parameter | Persistent sub-agents by ID |
| API | Single task tool call | spawn + delegate commands |
| Best for | Expert delegation, multi-turn workflows | Fan-out / fan-in parallelism |
Ready-to-run Example
This example is available on GitHub: examples/01_standalone_sdk/40_task_tool_set.py
examples/01_standalone_sdk/40_task_tool_set.py
The model name should follow the LiteLLM convention:
provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.Next Steps
- Sub-Agent Delegation — Parallel task execution with DelegateTool
- Custom Tools — Build your own tools
- Skills — Configure agent behavior with skills

