Implementation:Ucbepic Docetl Directive IsolatingSubtasks
| Knowledge Sources | |
|---|---|
| Domains | Pipeline_Optimization, LLM_Operations |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for rewriting a single Map into a Parallel Map that isolates subtasks with independent outputs provided by the DocETL reasoning optimizer.
Description
The IsolatingSubtasksDirective class rewrites a single Map into a Parallel Map that isolates subtasks and generates separate outputs for each, followed by a Map that aggregates or synthesizes the results. This allows independent subtasks to be handled in parallel before combining into a unified output, improving both accuracy and throughput for multi-faceted operations.
Usage
The MOAR agent applies this directive when the original Map is overloaded -- either the prompt asks for many different things or the output schema has many fields -- and subtasks are better handled independently (e.g., extract each attribute in parallel, then combine into a unified output).
Code Reference
Source Location
- Repository: Ucbepic_Docetl
- File: docetl/reasoning_optimizer/directives/isolating_subtasks.py
- Lines: 1-412
Signature
class IsolatingSubtasksDirective(Directive):
name = "isolating_subtasks"
description = "Rewrites a single Map into a Parallel Map that isolates subtasks, followed by a Map to aggregate results."
def check_applicability(self, ...) -> Tuple[bool, str]: ...
def apply(self, ...) -> Tuple[List[Dict], List[Dict], str, dict]: ...
Import
from docetl.reasoning_optimizer.directives.isolating_subtasks import IsolatingSubtasksDirective
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| op_config | Dict | Yes | Operation configuration to transform |
| pipeline_ops | List[Dict] | Yes | Full pipeline operations list |
| op_idx | int | Yes | Index of target operation |
| dataset_descriptions | Dict | Yes | Dataset schema descriptions |
Outputs
| Name | Type | Description |
|---|---|---|
| new_ops | List[Dict] | Transformed operation configs |
| new_steps | List[Dict] | Updated pipeline steps |
| explanation | str | Human-readable description of changes |
| metadata | dict | Additional metadata about the transformation |
Usage Examples
# Directives are typically invoked by the MOAR agent automatically
# Example of manual invocation:
from docetl.reasoning_optimizer.directives.isolating_subtasks import IsolatingSubtasksDirective
directive = IsolatingSubtasksDirective()
applicable, reason = directive.check_applicability(op_config, pipeline_ops, op_idx, dataset_descriptions)
if applicable:
new_ops, new_steps, explanation, metadata = directive.apply(op_config, pipeline_ops, op_idx, dataset_descriptions)