Overview
Tool Name
Purpose
The process_manager_tools enable orchestration of complex, multi-step workflows and coordination of multiple agents working together. Manage long-running processes, delegate tasks to specialized agents, track progress across distributed operations, and implement sophisticated data pipelines with parallel execution, error handling, and state management. Perfect for enterprise-scale data operations, multi-phase projects, and collaborative agent workflows.Functions Available
_delegate_work
:Delegate tasks to other bots and WAIT for completion (synchronous blocking operation).
sub_thread
:Create isolated execution contexts for focused tasks with optional tool constraints and async execution.
repeat
:Execute instruction repeatedly for each item in a list (synchronous sequential processing).
check_sub_thread_status
:Check the status of an async sub-thread execution.
get_sub_thread_messages
:Retrieve conversation history from a sub-thread.
Key Features
Work Delegation
Delegate tasks to specialized agents and wait for completion with comprehensive results.
Sub-Thread Isolation
Create isolated execution contexts with constrained tools for focused, secure task execution.
Batch Processing
Execute the same instruction across multiple items with sequential or parallel processing.
Async Execution
Start long-running tasks asynchronously and check status later without blocking.
Tool Constraints
Restrict available tools in sub-threads for security and focused execution.
Context Management
Control whether sub-threads inherit parent context or start fresh.
Input Parameters for Each Function
_delegate_work
Parameters
Name | Definition | Format |
---|---|---|
prompt | COMPLETE instructions for the task. Provide ALL details in this single call—the function will WAIT for completion. | String (required) |
target_bot | Bot ID or name to delegate to. The function BLOCKS until this bot completes the task or times out. | String |
timeout_seconds | Maximum seconds to WAIT for task completion before timing out (default 300). Function blocks for this duration. | Integer |
max_retries | Maximum retries if bot returns invalid JSON (during the single synchronous execution). | Integer |
sub_thread
Parameters
Name | Definition | Format |
---|---|---|
task | Specific task or prompt to execute in the sub-thread. | String (required) |
allowed_tools | List of tool names that can be used in sub-thread (e.g., [‘read_file’, ‘write_file’]). Empty = all tools. | Array of Strings |
include_context | Whether to include main thread’s conversation context (default: False). | Boolean |
async_mode | If True, returns immediately with thread_id for later checking (default: False for synchronous behavior). | Boolean |
timeout_seconds | Maximum seconds to wait for sub-thread completion. | Integer |
callback_url | Optional URL to POST results to when complete (useful for async mode). | String |
resume_thread_id | ID of existing sub-thread to resume (must start with ‘sub_thread_’). | String |
stop_on_timeout | If True (default), stop remote work on timeout; if False, leave running and return partial result. | Boolean |
repeat
Parameters
Name | Definition | Format |
---|---|---|
instruction | Base instruction to repeat for each item. Each iteration runs SYNCHRONOUSLY to completion before next starts. | String (required) |
items | List of parameters to iterate over (max 20 items). Function processes each SEQUENTIALLY, waiting for completion. | Array of Objects |
timeout_seconds | Maximum seconds to WAIT for EACH iteration to complete (not total time). Function blocks for each item. | Integer |
max_retries | Maximum retries if bot returns invalid JSON (per iteration during synchronous execution). | Integer |
check_sub_thread_status
Parameters
Name | Definition | Format |
---|---|---|
thread_id | Sub-thread ID to check status for (must start with ‘sub_thread_’). | String (required) |
last_n_messages | Optional: include last N user/assistant messages (default 0 = none). | Integer |
get_sub_thread_messages
Parameters
Name | Definition | Format |
---|---|---|
thread_id | Sub-thread ID to retrieve messages from (must start with ‘sub_thread_’). | String (required) |
last_n_messages | Number of most recent messages to retrieve (default: 10). | Integer |
include_tool_calls | Include sanitized tool calls and tool results (default: True). | Boolean |
Critical Understanding:
_delegate_work
and repeat
are BLOCKING functions that wait for completion. Use sub_thread
with async_mode=True
for non-blocking operations.Use Cases
- Multi-Agent Collaboration Coordinate multiple specialized agents (data analyst, report generator, quality checker) to complete complex projects.
- Parallel Data Processing Process multiple datasets, files, or customers simultaneously by delegating to multiple agent instances.
- Long-Running Operations Execute time-intensive tasks (model training, large data processing) asynchronously without blocking main workflow.
- Tool-Constrained Execution Run code with restricted tool access for security or to prevent unintended operations.
- Batch Operations Apply the same analysis, transformation, or report generation across multiple entities (customers, products, regions).
Workflow/How It Works
-
Step 1: Simple Task Delegation
Delegate a task to another bot and wait for results:
-
Step 2: Sub-Thread with Tool Constraints
Execute task with limited tools for security:
-
Step 3: Async Sub-Thread for Long Operations
Start a long-running task without blocking:
-
Step 4: Batch Processing with Repeat
Process multiple items sequentially:
-
Step 5: Multi-Agent Pipeline
Coordinate multiple agents for complex workflow:
-
Step 6: Resume Interrupted Sub-Thread
Continue work from previous sub-thread:
Integration Relevance
- project_manager_tools to orchestrate complex missions with multiple tasks and agents.
- process_scheduler_tools to schedule batch operations and multi-agent workflows.
- data_connector_tools with delegation for parallel data extraction across multiple sources.
- github_connector_tools / gitlab_connector_tools for coordinated version control operations.
- airflow_tools to trigger multi-agent pipelines from Airflow DAGs.
- code_executor_tools within sub-threads for sandboxed code execution.
Configuration Details
- Delegation Mode: Synchronous blocking—waits for delegated bot to complete before returning.
- Sub-Thread Isolation: Each sub-thread has independent context and variable scope.
- Tool Constraints: Sub-threads can restrict tools to specific subsets for security.
- Timeout Handling: Configurable timeout with option to stop or continue on timeout.
- Context Inheritance: Sub-threads can optionally inherit parent thread conversation history.
- Async Support: Sub-threads support async mode for non-blocking long operations.
- Thread Tracking: All sub-threads tracked with unique IDs for status checking.
- Error Propagation: Errors in delegated/sub-thread work returned to caller for handling.
Blocking Behavior:
_delegate_work
and repeat
are BLOCKING operations. They will NOT return until the work completes or times out. Plan your timeout values accordingly.Limitations or Notes
- Blocking Operations:
_delegate_work
andrepeat
block execution—cannot check status or cancel mid-execution. - Timeout Limits: Default 300 seconds (5 minutes); maximum timeout may be system-configured.
- Sequential Repeat:
repeat
processes items one at a time—not parallel (use multiplesub_thread
calls for parallel). - Item Limit:
repeat
maximum 20 items per call to prevent excessive execution time. - Context Size: Including context in sub-threads increases memory usage—use sparingly.
- Tool Availability: Delegated bots must have required tools; sub-threads inherit from parent unless constrained.
- Thread Lifecycle: Sub-threads cleaned up after completion; results available only while tracked.
- No Nested Delegation: Sub-threads cannot create their own sub-threads (one level deep only).
Supported Operations
✅ _delegate_work - Synchronous task delegation to other bots✅ sub_thread (sync) - Blocking isolated execution with tool constraints
✅ sub_thread (async) - Non-blocking isolated execution
✅ repeat - Sequential batch processing
✅ check_sub_thread_status - Status checking for async sub-threads
✅ get_sub_thread_messages - Retrieve sub-thread conversation
✅ resume_thread_id - Resume interrupted sub-threads
✅ callback_url - Webhook notification on completion
Not Supported
❌ Parallel execution of repeat items (sequential only)❌ Canceling in-progress _delegate_work (waits for timeout)
❌ Nested sub-threads (sub-thread creating sub-threads)
❌ Real-time progress updates during delegation
❌ Partial result retrieval before completion
❌ Dynamic timeout adjustment during execution
❌ Cross-bot state sharing (each execution isolated)
❌ Priority or queue management for delegations
Output
- _delegate_work: Dict with
success
,result
(bot’s response),callback_id
(thread ID reference),error
. - sub_thread (sync): Dict with
success
,result
,thread_id
,error
. - sub_thread (async): Dict with
success: True
,async: True
,thread_id
,message
. - repeat: Dict with
success
,results
(list),errors
,completed_iterations
,total_iterations
. - check_sub_thread_status: Dict with
found
,status
(‘running’, ‘completed’, ‘error’),result
,error
,started_at
. - get_sub_thread_messages: Dict with
found
,thread_id
,messages
,message_count
,returned_count
. - Errors: Detailed error messages with context about what failed and why.
Best Practices
Complete Instructions
Provide ALL context and details in delegation prompt. Delegated bot won’t have access to your conversation history.
Appropriate Timeouts
Set realistic timeouts based on task complexity. Too short = premature failure, too long = wasted wait time.
Error Handling
Always check for errors in results. Delegated tasks may fail—handle gracefully and retry if appropriate.
Tool Constraints
Use allowed_tools to restrict sub-thread capabilities when security or focus is important.
Async for Long Tasks
Use async sub-threads for operations > 1 minute to avoid blocking. Check status periodically.
Context Awareness
Only include context when necessary. Increases memory usage and can introduce confusion for focused tasks.
Example: Complete Multi-Agent Workflow
Advanced Features
Parallel Processing Pattern
Execute multiple independent tasks simultaneously:Error Recovery and Retry
Implement retry logic for delegated work:Conditional Workflows
Implement decision logic in multi-agent workflows:Progressive Enhancement
Build results incrementally across agents:Troubleshooting
Delegation Timeout
Delegation Timeout
- Increase timeout_seconds parameter
- Check if target bot is responsive
- Verify task complexity matches timeout
- Break complex tasks into smaller delegations
- Check target bot has required tools
- Review target bot’s execution history
Sub-Thread Stuck in Running State
Sub-Thread Stuck in Running State
- Check timeout configuration
- Review task complexity
- Verify allowed_tools include what’s needed
- Check for infinite loops in task logic
- Use check_sub_thread_status to get details
- Consider killing stuck thread and restarting
Repeat Fails on Specific Items
Repeat Fails on Specific Items
- Check errors list in repeat result
- Verify all items have required fields
- Test instruction with problem items manually
- Add error handling to instruction
- Reduce timeout if items timing out
- Check for data-specific issues
Context Not Available in Sub-Thread
Context Not Available in Sub-Thread
- Set include_context=True explicitly
- Verify parent thread has context to share
- Note context increases memory usage
- Consider passing needed data explicitly
- Check context size isn’t too large
- Use resume_thread_id if continuing work
Tool Restriction Issues
Tool Restriction Issues
- Verify allowed_tools list is correct
- Check tool names match exactly
- Empty list = all tools available
- Test with broader tool access first
- Review error for which tool was blocked
- Add missing tools to allowed_tools
Async Sub-Thread Status Unknown
Async Sub-Thread Status Unknown
- Verify thread_id is correct (starts with ‘sub_thread_’)
- Check thread hasn’t been cleaned up
- Allow time for status to update
- Use get_sub_thread_messages for more details
- Check if thread completed while not monitoring
- Verify tracking system is functioning
Incomplete Results from Delegation
Incomplete Results from Delegation
- Provide more complete instructions in prompt
- Check target bot understood requirements
- Review returned result structure
- Add explicit format requirements to prompt
- Increase timeout if bot needs more time
- Test prompt manually with target bot first
Process Manager Architecture
Understanding the orchestration components:Key Concepts
- Delegation: Synchronous blocking call to another bot—waits for completion
- Sub-Thread (Sync): Isolated execution that blocks until complete
- Sub-Thread (Async): Non-blocking execution with status checking
- Repeat: Sequential iteration blocking on each item
- Tool Constraints: Filter available tools in sub-threads
- Context Inheritance: Optional sharing of conversation history
Performance Considerations
Appropriate Blocking
Understand when operations block. Plan workflow to minimize unnecessary waiting.
Timeout Tuning
Set timeouts based on actual task duration. Monitor execution times and adjust.
Parallel When Possible
Use async sub-threads for independent tasks. Don’t use repeat when parallel execution is better.
Context Size
Only include context when necessary. Large contexts slow execution and increase memory.
Comparison: Orchestration Options
Feature | _delegate_work | sub_thread (sync) | sub_thread (async) | repeat |
---|---|---|---|---|
Execution Model | Blocking | Blocking | Non-blocking | Blocking sequential |
Use Case | Task to another bot | Isolated execution | Long-running tasks | Batch processing |
Tool Control | ❌ No | ✅ Yes (allowed_tools) | ✅ Yes (allowed_tools) | ❌ No |
Context Inheritance | ❌ No | ✅ Optional | ✅ Optional | ❌ No |
Status Checking | ❌ Waits for completion | ❌ Waits for completion | ✅ check_sub_thread_status | ❌ Waits for completion |
Best For | Bot collaboration | Focused secure tasks | Async operations | Multiple similar items |
Choosing the Right Tool:
- Need another bot’s expertise? Use _delegate_work
- Need tool restrictions? Use sub_thread with allowed_tools
- Task takes > 1 minute? Use sub_thread async_mode=True
- Same task for multiple items? Use repeat
Best Practices Summary
- Always provide complete instructions in delegation prompts—no context is shared
- Set realistic timeouts based on task complexity
- Use async mode for long-running operations (> 1 minute)
- Implement error handling for all delegation/sub-thread calls
- Constrain tools in sub-threads when security or focus is important
- Monitor execution via status checks for async operations
- Break complex workflows into smaller, focused delegations
- Test prompts manually before using in automated workflows
- Log execution details for debugging and optimization
- Consider parallel execution instead of sequential when tasks are independent