Inferensys

Prompt

Complex Task Decomposition Prompt Template

A practical prompt playbook for agent framework developers who need to break a complex user request into a dependency-ordered list of executable sub-tasks with clear input/output contracts and agent role assignments.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, the ideal user, and the boundaries of the Complex Task Decomposition Prompt Template.

This prompt is designed for agent framework developers and orchestration engineers who need to break a single, complex user request into a dependency-ordered list of executable sub-tasks. The primary job-to-be-done is transforming an ambiguous or multi-faceted objective into a structured execution plan where each sub-task has a clear owner, input/output contract, and completion criteria. The ideal user is building or operating a multi-agent system and needs a reliable, machine-readable decomposition that can be passed to a task orchestrator or a pool of specialized agents.

Use this prompt when the incoming request is too large for a single agent to handle reliably, requires multiple distinct capabilities, or has internal dependencies that must be respected. It is appropriate for requests that involve research-then-write workflows, data collection followed by analysis, or any scenario where parallel execution of independent sub-tasks can reduce latency. The prompt expects a well-defined [USER_REQUEST] and, optionally, a [CAPABILITY_REGISTRY] describing available agents and their skills. It works best when you can provide concrete [CONSTRAINTS] such as latency budgets, context window limits, or required approval gates.

Do not use this prompt for simple, single-step requests that a single agent can complete in one turn. Avoid it when the user request is already a well-scoped task with no internal dependencies, or when the overhead of decomposition and handoff exceeds the execution time of the task itself. This prompt is also not a planning prompt for autonomous agents that must discover their own capabilities at runtime—it assumes you have a known agent pool. If the request involves high-stakes actions such as financial transactions, clinical decisions, or legal filings, the decomposition output must include explicit human approval gates and cannot be executed autonomously without review. For those scenarios, pair this prompt with the Human-in-the-Loop Handoff Structuring Prompt and ensure every sub-task carries a [RISK_LEVEL] marker that triggers escalation when confidence is low.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Complex Task Decomposition Prompt Template works well, where it breaks, and the operational prerequisites for using it in a multi-agent system.

01

Good Fit: Greenfield Multi-Agent Orchestration

Use when: building a new orchestrator that must break a complex, ambiguous user request into a dependency-ordered task list for a pool of specialized agents. Guardrail: Start with a small, static agent pool (3-5 agents) and well-defined capability contracts before scaling to dynamic discovery.

02

Bad Fit: Real-Time, Low-Latency Pipelines

Avoid when: the system requires sub-second responses or the decomposition step itself adds unacceptable latency. Guardrail: For latency-sensitive paths, use a pre-compiled task graph or a cached decomposition plan. Reserve this prompt for asynchronous, high-value, or one-off complex tasks.

03

Required Input: Structured Agent & Tool Manifests

Risk: The model hallucinates agent capabilities or invents tools that don't exist, producing an unexecutable plan. Guardrail: Always provide a strict, machine-readable manifest of available agents, their input/output contracts, and their tools as part of the prompt's [AGENT_CAPABILITIES] input. Validate the output plan against this manifest.

04

Required Input: A Clear, Non-Trivial User Objective

Risk: The prompt is overkill for simple, single-step tasks and will produce an overly complex, wasteful plan. Guardrail: Implement a complexity classifier upstream. Route simple tasks directly to a single agent and only invoke this decomposition prompt for requests that match a complexity threshold (e.g., multiple verbs, cross-domain requirements).

05

Operational Risk: Dependency Chain Fragility

Risk: A single sub-task failure in a long dependency chain can cascade and invalidate all downstream work, wasting compute and time. Guardrail: Design the orchestrator to accept partial results and implement a Dynamic Re-Decomposition recovery path. The prompt's output must include explicit dependency types (e.g., hard vs. soft) to enable this.

06

Operational Risk: Context Budget Exhaustion

Risk: The orchestrator's context window fills up with verbose task definitions and contracts, leaving no room for the actual data to be processed by sub-agents. Guardrail: The prompt must be instructed to produce concise, token-efficient contracts. Pair this with a Context Budget Allocation prompt to enforce hard limits on the total size of the generated plan.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for decomposing complex tasks into executable sub-tasks with clear contracts.

This section provides a copy-ready prompt template that you can drop into your agent orchestration layer. The template is designed to take a complex user request, a set of available agent capabilities, and any known constraints, and produce a dependency-ordered task list. Each sub-task includes an input/output contract, an agent role assignment, and completion criteria. The template uses square-bracket placeholders for all dynamic inputs so you can wire it directly into your prompt assembly pipeline without manual editing.

text
You are a task decomposition planner for a multi-agent system. Your job is to break a complex user request into a set of executable sub-tasks that can be assigned to specialized agents.

## INPUT
User Request: [USER_REQUEST]

Available Agents and Capabilities:
[AGENT_CAPABILITIES]

Known Constraints:
[CONSTRAINTS]

Risk Level: [RISK_LEVEL]

## INSTRUCTIONS
1. Analyze the user request and identify all distinct work units required to fulfill it.
2. For each work unit, define a sub-task with a clear objective, required inputs, expected outputs, and completion criteria.
3. Assign each sub-task to the most appropriate agent from the available pool. If no agent is capable, flag the sub-task for human escalation.
4. Identify dependencies between sub-tasks. A sub-task cannot start until all its dependencies are completed.
5. Identify sub-tasks that can execute in parallel without data conflicts.
6. For each sub-task, estimate whether it is likely to succeed given the assigned agent's capabilities. Flag low-confidence assignments.
7. Produce the final plan as a dependency-ordered list.

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "plan_id": "string",
  "original_request_summary": "string",
  "sub_tasks": [
    {
      "task_id": "string",
      "objective": "string",
      "assigned_agent": "string",
      "confidence_score": 0.0-1.0,
      "confidence_rationale": "string",
      "required_inputs": ["string"],
      "expected_output": {
        "schema": "string describing the output shape",
        "required_fields": ["string"],
        "validation_rules": ["string"]
      },
      "completion_criteria": ["string"],
      "depends_on": ["task_id"],
      "parallelizable_with": ["task_id"],
      "escalation_trigger": "string or null",
      "estimated_effort": "low | medium | high"
    }
  ],
  "execution_order": ["task_id"],
  "unassigned_work": [
    {
      "description": "string",
      "reason": "string",
      "recommended_action": "escalate_to_human | request_new_agent | defer"
    }
  ],
  "warnings": ["string"]
}

## RULES
- Every sub-task must have at least one completion criterion.
- Dependencies must reference valid task_ids within the plan.
- Do not create circular dependencies.
- If the risk level is "high", flag any sub-task with confidence_score below 0.8 for human review.
- If no agent can perform a required work unit, list it in unassigned_work rather than forcing a bad assignment.
- Keep objectives specific and measurable. Avoid vague language like "handle the thing."

To adapt this template, replace each square-bracket placeholder with data from your orchestration layer. [USER_REQUEST] should contain the full user input, not a summary. [AGENT_CAPABILITIES] should list each available agent by name with a short capability description and any known limitations. [CONSTRAINTS] can include latency budgets, context window limits, cost caps, or policy restrictions. [RISK_LEVEL] should be one of low, medium, or high and controls whether low-confidence assignments trigger automatic human review. After copying the template, test it against at least three diverse user requests and validate that the output JSON parses correctly, contains no circular dependencies, and assigns every required work unit to either an agent or the unassigned_work list.

IMPLEMENTATION TABLE

Prompt Variables

Placeholders required by the Complex Task Decomposition Prompt Template. Replace each with concrete values before sending the prompt. Validation notes describe how to check that the input is well-formed and safe.

PlaceholderPurposeExampleValidation Notes

[USER_REQUEST]

The full, unmodified complex request from the end user or upstream system

Analyze our Q4 sales data, identify the top 3 underperforming regions, propose corrective actions, and draft a board-ready summary.

Non-empty string required. Check for embedded instructions or prompt injection patterns before passing through. Retain original wording; do not paraphrase.

[AVAILABLE_AGENTS]

A structured list of agent roles, capabilities, and current availability status

[ {"role": "data-analyst", "capabilities": ["sql", "statistics", "charting"], "available": true}, {"role": "strategist", "capabilities": ["business-analysis", "recommendations"], "available": true} ]

Must be valid JSON array. Each entry requires role, capabilities array, and available boolean. Reject if capabilities list is empty or role names collide. Validate against actual agent registry before dispatch.

[CONTEXT_BUDGET_PER_SUBTASK]

Maximum token allocation for context passed to each sub-agent

4000

Integer greater than 0. Must not exceed the target model's context window minus output reservation. Check that sum of all sub-task budgets plus orchestration overhead fits within total system budget.

[MAX_PARALLEL_DEPTH]

Maximum number of sub-tasks allowed to execute concurrently

4

Integer between 1 and the number of available agent slots. Setting too high risks resource contention; setting too low underutilizes agents. Validate against actual agent pool size and rate limits.

[OUTPUT_SCHEMA]

The required JSON schema each sub-task output must conform to

{"type": "object", "properties": {"result": {"type": "string"}, "confidence": {"type": "number", "minimum": 0, "maximum": 1}}, "required": ["result", "confidence"]}

Must be valid JSON Schema draft-07 or later. Parse and validate schema before injection. Reject schemas with circular references or unbounded recursion. Test with a known-valid sample output.

[COMPLETION_CRITERIA]

Measurable conditions that define when the overall task is done

All sub-tasks return confidence >= 0.8. No dependency chain is broken. Final output passes schema validation. Board summary includes at least 3 data-backed recommendations.

Each criterion must be testable in code. Avoid vague terms like 'good enough' or 'reasonable'. Write criteria as assertions that return true or false. At least one criterion must be present.

[ESCALATION_POLICY]

Rules for when a sub-task should escalate to a human or supervisor agent instead of retrying

Escalate if sub-task fails 2 retries. Escalate immediately if confidence < 0.5. Escalate if output violates safety policy. Route to [HUMAN_REVIEW_QUEUE] with full sub-task trace.

Must specify retry limits, confidence thresholds, and routing target. Validate that escalation target exists and is reachable. Test escalation path end-to-end before production use.

[HUMAN_REVIEW_QUEUE]

Identifier for the queue or system that receives escalated sub-tasks for human review

review-queue-sales-strategy

Non-empty string. Must match a configured queue name in the orchestration system. Validate queue exists and has active reviewers before dispatch. Log a warning if queue depth exceeds threshold.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Complex Task Decomposition prompt into an agent orchestration pipeline with validation, retries, and structured logging.

This prompt is not a one-off chat interaction; it is a critical planning step inside an agent orchestrator. The orchestrator calls this prompt before any sub-agent is dispatched. The output is a machine-readable task plan that the orchestrator parses, validates, and uses to drive execution. Treat the prompt's output as a control artifact—if the plan is malformed, the entire multi-agent pipeline must halt or fall back to a simpler execution path. Wire this prompt as a synchronous pre-execution gate, not an asynchronous advisory call.

The implementation harness requires three layers: input assembly, output validation, and execution dispatch. For input assembly, collect the user's original request, available agent capability descriptions, current system state, and any hard constraints (budget, latency, required approvals). Pack these into the [USER_REQUEST], [AGENT_POOL], [CONSTRAINTS], and [CONTEXT] placeholders. After the model responds, parse the JSON output and run a structural validator that checks for: (1) valid JSON syntax, (2) a non-empty sub_tasks array, (3) each sub-task having a unique task_id, a non-empty agent_role, and a defined input_contract and output_contract, (4) all depends_on values referencing existing task_id values, and (5) no circular dependencies in the dependency graph. If validation fails, retry the prompt once with the validation errors appended to the [CONSTRAINTS] field. If the second attempt fails, log the failure, notify a human operator, and route the request to a simpler single-agent fallback.

For production reliability, wrap the prompt call in a retry policy with exponential backoff (initial delay 1s, max 3 attempts for transient model errors). Log every decomposition attempt with a trace ID that links the user request, the raw prompt, the model response, validation results, and the final accepted plan. This trace is essential for debugging when downstream agents produce conflicting or incomplete work. When the plan passes validation, the orchestrator should serialize it into an execution graph and begin dispatching sub-tasks according to the dependency order. Monitor for runtime failures where a sub-task's actual output does not match its declared output_contract—this indicates a decomposition error that should be fed back into the prompt's eval dataset for future regression testing. Do not use this prompt for trivial single-step requests; implement a lightweight classifier upstream that bypasses decomposition entirely when the user's intent is clearly a single-turn query or a direct tool call.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape of the decomposition plan so the orchestrator can parse it reliably. Each field maps to a downstream validation rule.

Field or ElementType or FormatRequiredValidation Rule

decomposition_id

string (UUID v4)

Must match UUID v4 regex. Generated by the orchestrator, not the model.

original_request

string

Must be a non-empty string. Should be a verbatim copy of the [USER_REQUEST] input.

sub_tasks

array of objects

Array length must be >= 1. If empty, the decomposition is invalid and should be retried.

sub_tasks[].task_id

string (kebab-case)

Must match pattern ^task-[a-z0-9-]+$. Must be unique within the array.

sub_tasks[].description

string

Must be a non-empty string with at least 10 characters. Describes the work to be done.

sub_tasks[].agent_role

string

Must match one of the roles defined in [AGENT_REGISTRY]. Unknown roles trigger a capability mismatch error.

sub_tasks[].input_contract

object

Must contain a required_fields array and an optional_fields array. Schema must be valid JSON Schema.

sub_tasks[].output_contract

object

Must contain a required_fields array. Schema must be valid JSON Schema. Used to validate sub-agent output.

sub_tasks[].dependencies

array of task_id strings

Each string must reference a valid task_id from another sub-task. An empty array means no dependencies.

sub_tasks[].completion_criteria

object

Must contain a definition (string) and acceptance_tests (array of strings). At least one acceptance test is required.

execution_order

array of arrays of task_id strings

Represents a topological sort. Each inner array is a parallelizable group. All task_ids must be present exactly once.

critical_path

array of task_id strings

If present, must be a valid path through the dependency graph. Null is allowed if the orchestrator computes it separately.

estimated_total_steps

integer

Must be >= 1. Represents the sum of estimated steps across all sub-tasks. Used for progress tracking.

decomposition_confidence

number (0.0 to 1.0)

Must be a float between 0.0 and 1.0. Values below [CONFIDENCE_THRESHOLD] should trigger human review.

PRACTICAL GUARDRAILS

Common Failure Modes

Task decomposition prompts fail in predictable ways. Here are the most common failure modes and how to guard against them before they reach production.

01

Phantom Dependencies

What to watch: The decomposition creates tasks that depend on outputs from tasks that don't produce those outputs, or the dependency chain references fields that don't exist in the upstream contract. Guardrail: Validate every dependency edge against the actual output schema of the upstream task. Run a schema-to-schema check before dispatching any sub-task.

02

Over-Decomposition Overhead

What to watch: The prompt splits work into too many fine-grained sub-tasks, creating excessive handoff overhead, context serialization costs, and orchestration latency that outweighs any parallelism gain. Guardrail: Set a minimum task granularity threshold. If a sub-task's estimated compute is less than the handoff cost, merge it with a sibling. Include a granularity check in the decomposition prompt itself.

03

Missing Completion Criteria

What to watch: Sub-tasks are defined with vague boundaries like 'analyze the data' or 'summarize findings,' making it impossible for the orchestrator to determine when a task is actually done. Guardrail: Require every sub-task to include measurable completion criteria: specific output fields, assertion checks, or acceptance tests. The decomposition prompt should reject any task without unambiguous done conditions.

04

Context Starvation

What to watch: Sub-tasks are dispatched with insufficient context because the decomposition prompt didn't allocate enough of the original request, evidence, or upstream results to each agent. Sub-agents hallucinate or produce irrelevant outputs. Guardrail: Include a context packaging step that explicitly lists what each sub-task receives. Validate that every required input field has a source. Flag tasks where context exceeds a safety threshold of the available window.

05

Orphaned Outputs

What to watch: A sub-task completes successfully but its output is never consumed by any downstream task or the final response assembler. The work is wasted and the user never sees the result. Guardrail: After decomposition, run a reachability check: every task output must be consumed by at least one downstream task or included in the final output. Flag orphaned tasks before execution begins.

06

Silent Contract Drift

What to watch: The decomposition prompt defines input/output contracts, but sub-agents produce outputs that deviate from the expected schema, field names, or types. The orchestrator fails silently or propagates malformed data downstream. Guardrail: Enforce strict output validation at every handoff point. Each sub-task output must pass schema validation before the orchestrator accepts it. Reject and retry with the contract re-stated on failure.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of a task decomposition plan before dispatching sub-tasks to agents. Each criterion should be checked programmatically or via LLM-as-judge before the orchestrator proceeds.

CriterionPass StandardFailure SignalTest Method

Task Completeness

All user requirements from [USER_REQUEST] are covered by at least one sub-task with no gaps

A requirement from [USER_REQUEST] has no corresponding sub-task or is only partially addressed

LLM judge compares [USER_REQUEST] requirements list against sub-task descriptions; flag uncovered requirements

Dependency Validity

All [DEPENDENCY] references point to existing sub-task IDs and form a valid DAG with no cycles

A sub-task depends on a non-existent ID or a cycle is detected in the dependency graph

Parse [DEPENDENCY] fields; run cycle detection algorithm; reject if graph is not acyclic

Contract Clarity

Each sub-task has defined [INPUT_SCHEMA] and [OUTPUT_SCHEMA] with required fields, types, and validation rules

A sub-task is missing [INPUT_SCHEMA] or [OUTPUT_SCHEMA], or schemas contain ambiguous field descriptions

Schema parser checks for presence of both schemas; LLM judge scores field description clarity on 1-5 scale; fail below 4

Agent Assignment Fit

Each sub-task is assigned to an agent role whose [CAPABILITIES] match the task requirements

A sub-task requires a capability not listed in the assigned agent's [CAPABILITIES] manifest

Cross-reference sub-task requirements against agent capability registry; flag mismatches

Parallelization Safety

Sub-tasks marked for parallel execution share no mutable resources or conflicting side effects

Two parallel sub-tasks write to the same resource or have unacknowledged read-write conflicts

Static analysis of [RESOURCE_LOCKS] and [SIDE_EFFECTS] fields; flag overlapping write scopes

Completion Criteria Measurability

Each sub-task has [DONE_CONDITIONS] that are specific, verifiable, and not circular

A [DONE_CONDITION] references the sub-task's own output, uses vague terms like 'good enough', or cannot be evaluated automatically

LLM judge evaluates each [DONE_CONDITION] for measurability; fail if any condition is self-referential or unscorable

Context Budget Compliance

Sum of estimated token usage across all sub-task [CONTEXT_PACKAGE] fields does not exceed [MAX_CONTEXT_BUDGET]

Total estimated tokens exceed [MAX_CONTEXT_BUDGET] or a sub-task has no token estimate

Token estimator sums [CONTEXT_PACKAGE] sizes; compare against budget; flag overruns and missing estimates

Escalation Path Coverage

Every sub-task has a defined [ESCALATION_TRIGGER] and [FALLBACK_AGENT] or [HUMAN_REVIEW] path

A sub-task has null or missing [ESCALATION_TRIGGER] with no fallback defined

Check for non-null [ESCALATION_TRIGGER] on all sub-tasks; flag any task with both null trigger and null fallback

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add strict JSON schema enforcement for the task DAG. Include a [CONTRACT_VALIDATION] pass that checks every sub-task's input/output contracts for completeness before dispatch. Wire the decomposition output into an orchestrator that parses the DAG, enforces execution order, and collects results per contract.

Prompt modification

Add to the base prompt: "Return a JSON object with tasks (array of task objects with id, agent_role, input_contract, output_contract, depends_on, completion_criteria) and execution_order (topologically sorted task IDs)." Add a second validation prompt: "Review the following task decomposition. Flag any task with missing inputs, circular dependencies, or ambiguous completion criteria."

Watch for

  • Silent format drift where the model drops required fields under high load
  • Contracts that pass schema validation but are semantically incomplete
  • Dependency chains that are valid but create unnecessary serial bottlenecks
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.