Thread Delegation
Thread delegation allows an AI to delegate sub-tasks to other threads during a conversation. The delegating thread sends a prompt to a target thread, which processes it using its own model, system prompt, context, and tools, then returns the result. This enables specialized workflows where different threads handle different types of tasks.
Overview
In a typical workflow, a single thread handles all aspects of a conversation using one model and one set of tools. Thread delegation breaks this pattern by allowing the AI to route specific sub-tasks to other threads that are configured for those tasks. The delegation is transparent -- the AI decides when to delegate, sends the prompt, receives the result, and incorporates it into the ongoing conversation.
This is particularly valuable when different tasks require different configurations. A general-purpose thread can delegate research to a thread equipped with web search tools, code review to a thread using a specialized coding model, or translation to a thread with language-specific instructions.
How It Works
The Delegation Flow
- The AI in the main thread determines that a sub-task would benefit from delegation.
- It uses the
delegate_to_threadtool withaction="lookup"to find available target threads. - It identifies the appropriate target thread based on title, team, and configuration.
- It calls the tool again with
action="delegate", providing the target thread ID and a detailed prompt. - The prompt is sent to the target thread's API endpoint.
- The target thread processes the prompt using its own system prompt, context blocks, conversation history, model, and tools.
- The response is returned to the delegating thread.
- The AI incorporates the delegated response into its reply to the user.
Isolation
Delegated requests are isolated from the target thread's ongoing conversation. The delegation system wraps the prompt in explicit isolation instructions:
- The target thread treats the delegated prompt as a standalone request.
- It does not reference its own previous conversations.
- Only the response is returned -- the delegating thread does not gain access to the target thread's history or context.
- The delegation is tracked as an ephemeral run for cost and usage monitoring.
Setting Up Delegation
Enabling the Tool
Thread delegation uses the delegate_to_thread tool. To enable it:
- Open the thread where you want the AI to be able to delegate tasks.
- Go to thread settings and open the Tools configuration.
- Enable the Thread Delegation tool.
- Save the configuration.
The tool is categorized under Orchestration and is provided by Workbench.
Configuring Target Threads
Target threads do not require any special configuration to receive delegated prompts. Any thread that the user has access to can serve as a delegation target. However, for effective delegation, target threads should be configured with:
- A clear system prompt describing the thread's specialization
- Relevant context blocks providing the domain knowledge the thread needs
- Appropriate tools for the type of tasks it will handle
- A suitable model for the task complexity
Example configurations:
| Thread Purpose | System Prompt Focus | Recommended Tools | Suggested Model |
|---|---|---|---|
| Web Research | Research assistant, cite sources | Web search, URL scraping | GPT-4o or Claude |
| Code Review | Senior developer, focus on quality | Code analysis | Claude Opus or GPT-4o |
| Translation | Professional translator, preserve tone | None needed | GPT-4o or Claude |
| Data Analysis | Data scientist, statistical rigor | Python execution | GPT-4o |
| Content Writing | Marketing copywriter, brand voice | None needed | Claude Sonnet |
Thread Discovery
The delegation tool supports two actions:
Lookup (action="lookup"): Lists threads accessible to the user. Supports optional filters:
titleFilter-- Partial match on thread titleteamFilter-- Filter by team name or ID
The AI uses lookup to discover available threads before delegating. The response includes each thread's ID, title, team, model, and timestamps.
Delegate (action="delegate"): Sends a prompt to a specific thread. Requires:
targetThreadId-- The UUID of the target thread (obtained from lookup)prompt-- The full prompt to send, including all necessary context
Use Cases
Research Delegation
A main thread handling a complex project can delegate research tasks to a thread equipped with web search tools. The research thread finds and summarizes relevant information, and the main thread incorporates the findings without needing web search capabilities itself.
Example flow:
- User asks: "What are the latest GDPR compliance changes affecting SaaS companies?"
- Main thread delegates to a research thread with web search tools.
- Research thread searches the web, compiles findings.
- Main thread receives the research and drafts a compliance summary.
Specialized Analysis
Different analysis tasks may benefit from different models or tool configurations. A general-purpose thread can delegate financial analysis to a thread with spreadsheet tools, or technical analysis to a thread with code execution capabilities.
Multi-Language Translation
A thread handling international communications can delegate translation tasks to threads configured for specific language pairs, each with appropriate system prompts defining translation style and terminology.
Parallel Expertise
A consulting thread can delegate to multiple specialized threads to gather diverse perspectives. For example, delegating the same business question to a financial analysis thread and a market research thread, then synthesizing their responses.
Delegation Chain
A target thread can itself have the delegation tool enabled, allowing it to delegate sub-sub-tasks to other threads. This creates a delegation chain where complex tasks are decomposed across multiple specialized threads.
Considerations for delegation chains:
- Each delegation adds latency (the full request-response cycle for the target thread)
- Token costs accumulate across all threads in the chain
- Each delegation is tracked as a separate ephemeral run
- There is no built-in depth limit, but practical latency constraints apply
Cost and Tracking
Each delegation creates an ephemeral run in the target thread. Ephemeral runs:
- Track input and output tokens separately
- Record cost based on the target thread's model pricing
- Are marked with
ephemeral_source: thread_delegation - Appear in the cost analytics for the target thread
- Do not create persistent messages in the target thread's conversation
The delegating thread's own run also records its tokens and costs. The total cost of a delegated interaction is the sum of the delegating run and all ephemeral runs.
Best Practices
- Name target threads clearly -- Use descriptive titles like "Research Assistant - Web Search" or "Code Reviewer - TypeScript". The AI uses thread titles to identify appropriate delegation targets.
- Include context in the prompt -- The target thread has no knowledge of the delegating thread's conversation. Include all necessary context in the delegation prompt. The tool description explicitly instructs the AI to be thorough.
- Limit delegation depth -- While chains are possible, each level adds latency and cost. Design your thread architecture to minimize unnecessary delegation layers.
- Monitor costs -- Delegation multiplies token usage across threads. Check the cost analytics to ensure delegation patterns remain cost-effective.
- Configure access carefully -- The AI can only delegate to threads the user has access to. Ensure team permissions are set correctly for shared delegation targets.
- Use lookup before delegating -- The AI should always look up available threads before delegating to ensure the target exists and is appropriately configured.
- Specialize target threads -- The value of delegation comes from specialization. Configure each target thread with focused system prompts, relevant context, and appropriate tools rather than creating generic catch-all threads.
Related Documentation
- Threads - Thread management and configuration
- Tools Overview - Understanding tool configuration and usage
- System Prompts - Configuring thread specialization
- Cost Analytics - Monitoring delegation costs
- Teams - Team access and permissions for shared threads
