This prompt is for agent architects and workflow engine developers who need to convert a complex objective into a structured, executable task graph with explicit prerequisite relationships. Use it when your agent orchestrator requires a valid topological ordering of subtasks, parallel execution groups, and a clear dependency map before execution begins. The output is a directed acyclic graph (DAG) of subtasks, not a flat list. This prompt belongs in the planning phase of an agent loop, after goal clarification but before tool selection and execution. It assumes you have already defined the objective and available tool set.
Prompt
Dependency-Aware Task Decomposition Prompt

When to Use This Prompt
Defines the ideal use case, required context, and boundaries for the dependency-aware task decomposition prompt.
Do not use this prompt for simple linear workflows where ordering is obvious; a basic step-by-step decomposition prompt is cheaper and faster for those cases. This prompt is also inappropriate when the objective is too ambiguous to decompose meaningfully—run a goal clarification prompt first. The prompt requires a well-scoped objective, a known tool inventory, and any domain constraints as inputs. If your agent operates in a high-risk domain like healthcare or finance, you must pair this prompt with a human-in-the-loop approval gate before executing any irreversible actions identified in the task graph.
Before integrating this prompt, ensure your harness can validate the output for cycles, missing dependencies, and tasks that depend on outputs from later steps. The prompt produces a machine-readable structure, so your orchestration layer should parse and verify the DAG before execution. For production systems, log the generated task graph alongside the execution trace to enable post-hoc debugging when plans fail. If your workflow requires dynamic replanning, use this prompt as the initial plan generator and pair it with a separate replanning prompt that can update the graph when tool failures or unexpected outputs invalidate the original structure.
Use Case Fit
Where the Dependency-Aware Task Decomposition Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your agent architecture before you integrate it.
Good Fit: Multi-Step Agent Orchestrators
Use when: Your agent must execute a complex objective that requires a specific sequence of tool calls, where later steps consume the output of earlier steps. Guardrail: Validate the generated DAG for cycles before execution. A topological sort failure should halt the plan, not silently drop edges.
Good Fit: Parallel Execution Planning
Use when: You need to minimize end-to-end latency by identifying independent subtasks that can run concurrently. Guardrail: The harness must compare the model's parallel groups against a shared-resource conflict map. Flag any group that accesses the same mutable file, database row, or API endpoint with write permissions.
Bad Fit: Single-Step Tool Calls
Avoid when: The user's request can be satisfied by a single function call with no ordering constraints. Guardrail: Implement a complexity gate before invoking this prompt. If the objective requires fewer than two tool calls, route to a simpler action-selection prompt to avoid unnecessary token cost and planning latency.
Required Input: A Known Tool Manifest
Risk: Without a strict tool list, the model will hallucinate plausible but unavailable capabilities, creating subtasks that cannot be executed. Guardrail: Always provide a closed tool manifest with function names, argument schemas, and side-effect descriptions. Post-process the output to reject any subtask that references an undefined tool.
Required Input: A Clear Termination Criterion
Risk: The model may decompose a goal into an unbounded or overly granular task list, wasting tokens and execution time. Guardrail: Include an explicit completion definition in the prompt, such as a final output schema or a specific state condition. Enforce a maximum subtask count in the harness and trigger a replan if exceeded.
Operational Risk: Silent Dependency Failures
Risk: A subtask fails at runtime, but downstream tasks execute anyway on stale or missing inputs, corrupting the final result. Guardrail: The execution engine must enforce strict dataflow contracts. Before running any task, verify that all its declared upstream dependencies have completed successfully and that their output artifacts exist and are valid.
Copy-Ready Prompt Template
A copy-ready prompt that instructs the model to decompose a complex objective into a dependency-aware task graph with explicit edges and parallel execution groups.
This prompt template is designed for agent orchestrators and planning modules that need more than a flat list of subtasks. It instructs the model to produce a directed acyclic graph (DAG) of tasks, where each task declares its prerequisites and its membership in a parallel execution group. The output is structured JSON that your execution harness can directly consume to schedule work, detect cycles, and identify tasks that are safe to run concurrently. Before using this prompt, ensure your model supports structured JSON output and has a context window large enough to accommodate your full tool list plus the expected output size. For high-risk or irreversible actions, always gate execution behind human approval steps and validate the plan's topological ordering before any tool is invoked.
textYou are a planning agent that decomposes complex objectives into a dependency-aware task graph. Your output must be valid JSON conforming to the schema below. OBJECTIVE: [OBJECTIVE] AVAILABLE TOOLS: [TOOLS] CONSTRAINTS: [CONSTRAINTS] OUTPUT SCHEMA: { "goal_summary": "A one-sentence restatement of the clarified objective.", "assumptions": ["List any assumptions you made during decomposition."], "tasks": [ { "task_id": "string, unique identifier", "description": "string, what this task does", "tool": "string or null, the tool required from AVAILABLE TOOLS", "depends_on": ["list of task_ids that must complete before this task starts"], "parallel_group": "string or null, tasks with the same non-null value can execute concurrently", "completion_criteria": "string, verifiable condition that defines task success", "output_schema": "string or null, expected shape of the task output" } ], "parallel_groups": [ { "group_id": "string", "task_ids": ["list of task_ids in this group"], "shared_resources": ["list any mutable resources shared across these tasks"] } ] } RULES: 1. Every task must have a unique task_id. 2. The depends_on field must reference only valid task_ids defined in the tasks array. 3. The dependency graph must be acyclic. No circular dependencies. 4. Tasks in the same parallel_group must not depend on each other. 5. If a task requires a tool not in AVAILABLE TOOLS, flag it in the assumptions array and do not assign a tool. 6. For high-risk or irreversible actions, set the completion_criteria to include a human approval gate. 7. Every task must have at least one completion_criteria. 8. If the objective is ambiguous, add clarification questions to the assumptions array.
After pasting this template, replace each square-bracket placeholder with your specific context. [OBJECTIVE] should contain the user's goal or the system's high-level instruction, stated as clearly as possible. [TOOLS] should be a structured list of available functions, APIs, or capabilities, each with a name, description, and parameter schema. If your tool definitions are long, consider placing them in system context rather than inline to preserve prompt real estate. [CONSTRAINTS] should capture hard limits such as time budgets, forbidden actions, required approval gates, data residency rules, or output format requirements. The output schema is embedded directly in the prompt to guide structured generation; if your model provider offers a native JSON mode or function-calling interface, you can move the schema to the API parameter and simplify the prompt body. Always test the prompt with objectives of varying complexity to ensure the model does not produce tasks with hallucinated tools or circular dependencies.
Prompt Variables
Inputs the prompt needs to work reliably. Validate each before sending. Missing or malformed variables are the most common cause of silent failures in dependency-aware decomposition.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[OBJECTIVE] | The high-level goal or task to decompose into subtasks with dependencies | Migrate the user authentication module from session-based to JWT-based authentication across a React frontend and Express backend | Required. Must be a non-empty string. Reject if length < 20 characters or contains only vague verbs like 'improve' or 'fix' without scope. Parse check: string type, min length. |
[CONTEXT] | Background information about the system, codebase, or environment where tasks will execute | Current auth stack: express-session with Redis store. Frontend in React 18. Backend in Express 4.18. Existing user model in PostgreSQL via Sequelize. No existing JWT implementation. | Required. Must be a non-empty string. Validate that context includes relevant system components, current state, and constraints. Reject if context is generic or contradicts the objective. Parse check: string type, min 50 characters. |
[AVAILABLE_TOOLS] | List of tools, APIs, or capabilities the agent can use to execute subtasks | ["read_file", "write_file", "search_codebase", "run_tests", "git_diff", "npm_install", "database_query"] | Required. Must be a valid JSON array of strings. Each tool name must be non-empty. Validate no duplicate tool names. Reject if array is empty or contains hallucinated tools not in the actual tool registry. Schema check: JSON array of strings. |
[CONSTRAINTS] | Boundaries, rules, or limitations that restrict how tasks can be executed | Cannot modify database schema. Must maintain backward compatibility with existing session-based auth during migration. Frontend and backend must be deployed together. No downtime permitted. | Optional but strongly recommended. If provided, must be a non-empty string. Validate that constraints are specific and actionable. Reject constraints that contradict each other. Parse check: string type. Null allowed if no explicit constraints exist. |
[OUTPUT_SCHEMA] | Expected JSON structure for the decomposed task list with dependencies | {"tasks": [{"id": "string", "description": "string", "depends_on": ["task_id"], "tool": "string", "completion_criteria": "string"}], "parallel_groups": [["task_id"]]} | Required. Must be a valid JSON Schema or example structure. Validate that schema includes fields for task ID, dependencies, tool assignment, and completion criteria. Reject schemas that lack dependency fields or parallel group specification. Schema check: valid JSON object with tasks array. |
[MAX_TASKS] | Upper bound on the number of subtasks to prevent over-decomposition or token explosion | 15 | Optional. If provided, must be a positive integer between 3 and 50. Default to 20 if not specified. Validate that the value is reasonable for the objective complexity. Reject values below 3 or above 100. Parse check: integer type, range 3-100. |
[REQUIRE_PARALLEL_GROUPS] | Flag indicating whether the output must identify tasks that can execute concurrently | Optional. Must be a boolean. Defaults to true for dependency-aware decomposition. When true, the output must include parallel_groups field. When false, only sequential dependency edges are required. Parse check: boolean type. | |
[CYCLE_DETECTION_LEVEL] | How aggressively the harness should check for dependency cycles in the output | strict | Optional. Must be one of: 'strict' (reject any cycle), 'warn' (flag cycles but return output), 'none' (skip cycle check). Defaults to 'strict'. Validate against allowed enum values. Parse check: string type, enum membership. |
Implementation Harness Notes
Wire the dependency-aware task decomposition prompt into an agent orchestrator with validation, retry, and logging to prevent cycles, missing dependencies, and hallucinated tools from reaching execution.
This prompt is designed to be called after goal clarification and before any execution step in an agent orchestrator. The orchestrator should parse the JSON output into a directed acyclic graph (DAG) structure where each node is a task with a unique task_id, a depends_on list, and a tool assignment. Before a single task executes, run a validation pipeline that checks four invariants: cycle detection, missing dependency references, tool existence against the [AVAILABLE_TOOLS] registry, and orphan detection. These checks prevent the most common and costly failure modes—deadlocked agents, hallucinated tool calls, and tasks that never get scheduled.
Implement cycle detection using either depth-first search with a visited-and-recursion-stack approach or Kahn's algorithm for topological sorting. If a cycle is found, capture the offending task IDs and inject the specific error message into the [CONSTRAINTS] field of a single retry attempt. For missing dependencies, iterate through every depends_on value and confirm it references an existing task_id in the plan; if a reference is dangling, include the missing ID in the retry constraint. Tool existence checks should compare every tool field against a canonical list of available tool names—this is where most hallucinated capabilities surface. Orphan detection ensures every task either appears as a dependency of at least one other task or is the designated final task; isolated tasks often indicate incomplete decomposition or forgotten objectives. If any validation check fails after one retry, escalate to a human operator with the full prompt, response, and validation failure details rather than looping indefinitely.
For production observability, log the complete prompt payload, the raw model response, the parsed task graph, and the results of each validation check. This trace is essential for debugging planning failures, tuning the prompt, and demonstrating governance to reviewers. In long-running workflows, store the validated task graph as the execution contract and monitor for runtime deviations—such as a task producing unexpected output that invalidates downstream assumptions—that should trigger a replanning cycle. Wire the validated graph into your execution engine with explicit state transitions: pending, ready (all dependencies satisfied), in_progress, completed, and failed. Use the dependency edges to compute parallel execution groups by identifying all tasks whose dependencies are satisfied at each step. Avoid the temptation to skip validation in low-risk demos; the same cycle and hallucination bugs that break production systems appear in development and erode trust in the planning module before it ever ships.
Expected Output Contract
Defines the required fields, types, and validation rules for the dependency-aware task decomposition response. Use this contract to build a parser, validator, and retry harness before integrating the prompt into an agent orchestrator.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
task_graph | object | Top-level key must exist and be a JSON object. Reject if missing or not an object. | |
task_graph.tasks | array of objects | Array must contain at least 1 task. Reject if empty or missing. Each element must be an object with a unique id field. | |
task_graph.tasks[].id | string | Must be unique across all tasks in the array. Use a set membership check. Reject on duplicate or missing id. | |
task_graph.tasks[].description | string | Must be a non-empty string with at least 10 characters. Reject if empty, whitespace-only, or missing. Warn if description is a duplicate of another task's description. | |
task_graph.tasks[].depends_on | array of strings | Each string must reference a valid task id present in the tasks array. Reject on dangling references. An empty array means no dependencies. Reject if the field is missing or not an array. | |
task_graph.tasks[].tool_assignment | string or null | If a string, must match an entry in the [AVAILABLE_TOOLS] list provided in the prompt. Use an allowlist check. If null, the task requires no tool call. Reject on hallucinated tool names. | |
task_graph.tasks[].completion_criteria | string | Must be a non-empty string describing a verifiable condition. Reject if missing. Warn if criteria are subjective (e.g., 'do it well') without a measurable signal. | |
task_graph.execution_order | array of arrays of strings | Must represent a valid topological sort of the task graph. Each inner array is a parallel execution group. Flattened list must contain every task id exactly once. Reject on missing tasks, extra tasks, or cyclic dependency violations. |
Common Failure Modes
Dependency-aware decomposition fails in predictable ways. These are the most common production failure modes and how to guard against them before they corrupt downstream execution.
Cyclic Dependencies
What to watch: The model produces a task graph where Task A depends on Task B, and Task B depends on Task A, creating a deadlock that halts execution. This often happens when tasks share bidirectional data requirements or when the model confuses logical ordering with mutual dependency. Guardrail: Run a topological sort on the output before execution. Reject any plan that contains cycles and request a revised decomposition with explicit ordering constraints. Add a schema rule that each dependency must reference a strictly earlier task ID.
Missing Dependencies
What to watch: A task requires an output from another task, but the dependency edge is absent from the graph. The orchestrator executes the dependent task too early, causing it to operate on stale, empty, or hallucinated inputs. This is common when the model assumes implicit data flow rather than declaring it. Guardrail: Validate that every input referenced in a task's context or tool arguments is produced by a task that appears earlier in the execution order. Flag any task that consumes an output not explicitly listed as a dependency.
Phantom Dependencies on Future Tasks
What to watch: A task declares a dependency on a task that appears later in the execution sequence, making the plan impossible to execute in the given order. This often occurs when the model generates dependencies by semantic association rather than by execution order. Guardrail: Enforce that all dependency task IDs must have a lower sequence index than the dependent task. Reject plans where any dependency points to a task with an equal or higher index. Request a re-sort with corrected ordering.
Over-Serialization of Independent Tasks
What to watch: The model chains tasks sequentially even when they share no data dependencies, wasting latency and compute. This happens when the model defaults to linear narrative rather than identifying true parallelism opportunities. Guardrail: After dependency extraction, compute the transitive closure and identify all task pairs with no path between them. Flag these as candidates for parallel execution groups. If the plan contains no parallel groups for a complex objective, prompt the model to re-evaluate independence.
Hallucinated Output Artifacts
What to watch: A task depends on a specific output field or artifact that the upstream task never actually produces. The orchestrator passes a null or fabricated value downstream, causing cascading failures or silent incorrectness. Guardrail: Define an explicit output schema for each task type. Validate that every dependency references an output field that exists in the upstream task's schema. Reject plans that reference undefined artifact names or field paths.
Incomplete Objective Coverage
What to watch: The decomposition omits a critical sub-goal from the original objective, producing a plan that executes successfully but fails to satisfy the user's intent. This is especially common when the objective contains implicit requirements or edge cases the model overlooks. Guardrail: After decomposition, run a coverage check that maps each clause of the original objective to at least one subtask. Flag any objective element with zero task coverage and request a revised decomposition that addresses the gap before execution begins.
Evaluation Rubric
How to test output quality before shipping. Run these checks on a golden dataset of 20-50 objectives with known-good decompositions.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Dependency Cycle Detection | Output contains zero directed cycles when traversed from any root node | A subtask lists a prerequisite that transitively depends on it, creating a loop | Run topological sort on the output graph; assert no nodes remain unvisited due to cycles |
Topological Order Validity | Every subtask appears after all its declared prerequisites in the execution order | A subtask is positioned before one or more of its [DEPENDENCIES] in the sequence | For each subtask, verify its index is greater than the index of every prerequisite in the ordered list |
Objective Coverage Completeness | All required outcomes from the [OBJECTIVE] are addressed by at least one subtask with a defined [ACCEPTANCE_CRITERIA] | A stated goal or constraint from the input has no corresponding subtask or is only partially addressed | Map each clause in the [OBJECTIVE] to one or more subtask descriptions; flag unmatched clauses |
Task Atomicity | Each subtask describes a single, verifiable unit of work with one clear owner and output | A subtask contains multiple distinct actions, tools, or owners joined by 'and' or spanning unrelated domains | Parse subtask descriptions for action verbs; flag any subtask with more than one primary action verb or tool call |
Dependency Completeness | Every subtask that consumes an output from another step explicitly lists that step as a prerequisite | A subtask references a resource, file, or state that is produced by a later step or not produced at all | Build a resource production-consumption map from output schemas; flag any consumed resource with no producer or a producer ordered after the consumer |
Parallel Group Safety | Subtasks marked as parallelizable share no mutable state, resources, or output targets | Two tasks in the same parallel group write to the same file, tool, or state variable | Cross-reference [PARALLEL_GROUPS] with resource write targets; flag any write-write or read-write conflict within a group |
Hallucinated Tool Detection | Every tool or capability referenced in a subtask exists in the provided [AVAILABLE_TOOLS] list | A subtask calls a function, API, or tool name not present in the input tool manifest | Extract all tool names from subtask descriptions; diff against [AVAILABLE_TOOLS] and flag any extras |
Output Schema Adherence | The response parses as valid JSON matching the expected [OUTPUT_SCHEMA] with all required fields present | JSON parse fails, required fields are missing, or field types are incorrect | Validate against the JSON Schema definition; assert no parse errors, no missing required fields, and correct types for all fields |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a frontier model and lighter validation. Focus on getting a valid DAG structure before investing in full harness logic. Replace [TOOL_CATALOG] with a simple list of available tool names and descriptions. Accept JSON output without strict schema enforcement initially.
Prompt modification
- Remove or simplify
[OUTPUT_SCHEMA]to request basictasksanddependenciesarrays without full metadata fields. - Add:
If you are uncertain about a dependency, mark it as 'possible' rather than omitting it. - Drop the
parallel_groupsrequirement until the dependency graph is stable.
Watch for
- Cycles that the model doesn't self-detect
- Tasks that depend on outputs from later steps
- Missing tool assignments when tools are available
- Overly granular subtasks that should be combined

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us