Inferensys

Prompt

Sub-Task Dependency Mapping Prompt Template

A practical prompt playbook for generating execution dependency graphs from decomposed sub-tasks in production multi-agent systems.
Developer reviewing multi-agent chat interface on laptop, agent conversation logs visible, casual coding session at WeWork desk.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise job-to-be-done for the Sub-Task Dependency Mapping prompt, identifying the ideal user, required inputs, and clear boundaries for when it should and should not be applied.

This prompt is for orchestration engineers who have already decomposed a complex task into a list of sub-tasks, each with clearly defined inputs and outputs. The job-to-be-done is to define the execution order by producing a directed acyclic graph (DAG). This graph must map data dependencies, identify opportunities for parallel execution, and flag blocking conditions where one task cannot start until another completes. The ideal user is an AI platform engineer or workflow builder who needs a machine-readable execution plan to prevent race conditions, missing inputs, and circular waits before dispatching work to agents.

Use this prompt when you have a complete sub-task list with explicit input/output contracts but need to determine the safe execution sequence. It is appropriate when the sub-tasks are well-scoped and you need to optimize for parallelism while avoiding dependency violations. Do not use this prompt to decompose a high-level goal into sub-tasks—that is the job of a task decomposition prompt. Do not use it to assign sub-tasks to specific agents or to define the schemas for sub-task inputs and outputs. This prompt assumes those steps are already complete. It also does not handle runtime re-planning if a sub-task fails mid-execution; that requires a dynamic re-decomposition prompt.

Before invoking this prompt, ensure you have a structured list of sub-tasks where each entry includes a unique identifier, a description, a list of required inputs with their data types, and a list of produced outputs. The prompt will fail silently or produce an invalid DAG if inputs and outputs are ambiguously named or if a sub-task's dependencies are not traceable to another sub-task's outputs. After receiving the DAG, validate it programmatically by checking for cycles, orphaned tasks with no path to completion, and missing inputs that are not produced by any upstream task. For high-stakes workflows, log the generated DAG for human review before handing it to an agent orchestrator.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Sub-Task Dependency Mapping Prompt Template delivers value and where it introduces risk. Use these cards to decide if this prompt fits your orchestration architecture.

01

Good Fit: Multi-Agent Orchestration Engines

Use when: you are building an orchestrator that decomposes complex requests into sub-tasks and needs to determine execution order before dispatching to specialized agents. Guardrail: validate the generated DAG against actual agent capability registries to ensure every leaf task has an assigned executor.

02

Bad Fit: Single-Agent Sequential Pipelines

Avoid when: your system uses a single agent that processes tasks sequentially with no parallelism or handoff. Dependency mapping adds unnecessary complexity and latency. Guardrail: use a simple ordered task list prompt instead; only introduce DAG generation when you have at least three agents and potential parallel execution paths.

03

Required Input: Complete Sub-Task Contracts

What to watch: the prompt cannot infer data dependencies without explicit input/output schemas for each sub-task. Missing contracts produce incomplete or incorrect dependency edges. Guardrail: require each sub-task to declare its required inputs and produced outputs in a structured schema before running dependency mapping.

04

Operational Risk: Undetected Cycles in Production

What to watch: the model may produce a DAG with subtle cycles when sub-tasks have mutual or circular dependencies, especially under high task complexity. Guardrail: always run a cycle detection algorithm on the generated graph before execution; never rely solely on the model's claim that the graph is acyclic.

05

Operational Risk: Orphaned Sub-Tasks

What to watch: the model may generate sub-tasks that have no downstream consumers or no upstream data sources, creating execution dead-ends or impossible starts. Guardrail: validate that every non-root task has at least one incoming edge and every non-leaf task has at least one outgoing edge before dispatching.

06

Bad Fit: Real-Time Low-Latency Systems

Avoid when: your system requires sub-100ms decision latency. LLM-based dependency mapping adds hundreds of milliseconds to seconds of overhead. Guardrail: pre-compute dependency graphs for known task patterns and use the prompt only for novel or edge-case decompositions that can tolerate higher latency.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

Paste this prompt into your orchestration layer to generate a validated dependency graph from a list of decomposed sub-tasks.

This template is designed to be dropped directly into an agent orchestrator or a planning step within a multi-agent framework. It takes a flat list of sub-tasks, each with defined inputs and outputs, and produces a directed acyclic graph (DAG) that enforces execution order. The prompt is structured to prevent cycles, identify orphaned tasks, and highlight parallelization opportunities before any agent is dispatched.

code
You are a workflow orchestration engine. Your task is to analyze a list of sub-tasks and produce a strict dependency map.

### INPUT
[SUB_TASK_LIST]

### CONSTRAINTS
- Produce a valid Directed Acyclic Graph (DAG). No cycles are permitted.
- A dependency exists only if Task B explicitly requires an output artifact produced by Task A.
- Do not infer dependencies based on topic similarity alone; rely strictly on matching output types to input requirements.
- Identify tasks with no dependencies (entry points) and tasks on which no other task depends (exit points).
- Flag any task that requires an input not produced by any other task in the list as an [ORPHANED_TASK].
- Flag any output artifact that is produced but never consumed as [UNUSED_OUTPUT].

### OUTPUT_SCHEMA
Return a single JSON object matching this structure:
{
  "dag": {
    "nodes": [
      {
        "task_id": "string",
        "description": "string",
        "input_artifacts": ["string"],
        "output_artifacts": ["string"],
        "status": "READY" | "BLOCKED"
      }
    ],
    "edges": [
      {
        "from_task_id": "string",
        "to_task_id": "string",
        "artifact": "string"
      }
    ]
  },
  "parallel_groups": [["task_id"], ["task_id"]],
  "validation_warnings": [
    {
      "type": "ORPHANED_TASK" | "UNUSED_OUTPUT" | "MISSING_INPUT",
      "task_id": "string",
      "detail": "string"
    }
  ]
}

### RISK_LEVEL
[HIGH_RISK_MODE]

To adapt this template, replace [SUB_TASK_LIST] with your structured array of tasks, ensuring each task object includes explicit input_artifacts and output_artifacts fields. The [HIGH_RISK_MODE] placeholder should be set to true if the workflow involves destructive actions, financial transactions, or unskippable compliance steps; when active, the orchestrator should block execution until all ORPHANED_TASK and MISSING_INPUT warnings are resolved by a human. After receiving the DAG, validate it programmatically by running a cycle-detection algorithm (e.g., depth-first search) on the returned edges before using the parallel_groups to dispatch work. If the model returns a cycle despite the constraints, reject the output and retry with a lower temperature setting or a stronger explicit penalty in the system prompt.

IMPLEMENTATION TABLE

Prompt Variables

Placeholders required by the Sub-Task Dependency Mapping prompt. Replace each with concrete values before execution. Validation notes describe how to verify the input is well-formed before the prompt runs.

PlaceholderPurposeExampleValidation Notes

[TASK_LIST]

Array of decomposed sub-tasks with IDs, descriptions, and agent assignments

task_3: Generate SQL migration script (assigned to db_agent)

Schema check: each entry must have id, description, assigned_agent fields. Null or empty array triggers abort.

[OUTPUT_SCHEMA]

Expected structure for the dependency graph output

JSON with nodes, edges, parallel_groups, blocking_conditions arrays

Schema check: must include nodes array and edges array. Missing fields cause downstream parsing failures.

[AGENT_CAPABILITIES]

Map of agent IDs to their input/output contracts and tool access

db_agent: accepts schema DDL, returns SQL; review_agent: accepts SQL, returns approval

Parse check: each agent must declare accepted_inputs and produced_outputs. Missing contracts block dependency inference.

[CONSTRAINTS]

Execution constraints like max parallelism, resource locks, or ordering rules

Migrations must run sequentially; read-only tasks can parallelize

Schema check: each constraint must have type (ordering|resource|timing) and scope. Ambiguous constraints cause false blocking.

[CONTEXT_BUDGET]

Total token budget available across all sub-tasks

120000 tokens shared across 8 sub-tasks

Range check: must be positive integer. Budget under 8000 tokens triggers warning; under 4000 triggers re-decomposition recommendation.

[FAILURE_MODE_MAP]

Known failure modes per sub-task with severity and recovery options

task_3: syntax error (retry), timeout (escalate), invalid schema (block downstream)

Schema check: each entry needs task_id, failure_type, severity, recovery_action. Missing entries mean orchestrator cannot recover.

[COMPLETION_CRITERIA]

Per-task done conditions that the orchestrator can verify programmatically

task_3: SQL file passes syntax check and review_agent approval

Parse check: each criterion must be evaluable by a validator function. Subjective criteria like 'looks correct' require human approval flag.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the dependency mapping prompt into an orchestration engine with validation, retries, and graph execution.

The sub-task dependency mapping prompt is not a standalone utility; it is the planning stage of a multi-agent orchestration pipeline. The prompt consumes a list of decomposed sub-tasks and produces a directed acyclic graph (DAG) with explicit data dependencies, parallelization groups, and blocking conditions. The output must be machine-readable so the orchestrator can execute the graph without re-parsing natural language. Treat the prompt output as a build artifact that is validated, versioned, and fed directly into a DAG executor such as LangGraph, Temporal, Prefect, or a custom state machine.

Validation before execution is mandatory. Before any agent is dispatched, run the output through a DAG validator that checks for: (1) cycles—any circular dependency must reject the plan and trigger a re-prompt with the cycle explicitly called out; (2) missing inputs—every sub-task's depends_on field must reference only sub-tasks present in the decomposition; (3) orphaned tasks—every sub-task must either be a terminal node or feed into at least one downstream task; (4) schema compliance—the output must match the expected JSON schema with task_id, depends_on, output_schema, parallel_group, and blocking_conditions fields. If validation fails, retry the prompt with the specific validation error injected into [CONSTRAINTS] as a correction directive. Do not proceed to execution with an invalid DAG.

Wiring into an orchestration engine follows a three-stage pattern. First, call the dependency mapping prompt with the decomposed task list and any resource constraints. Second, validate the DAG output using a deterministic validator (not an LLM). Third, translate the validated DAG into your orchestrator's execution model: map parallel_group values to concurrent execution slots, wire depends_on into task futures or promises, and attach blocking_conditions as pre-execution guards. For example, in a LangGraph implementation, each sub-task becomes a node, depends_on defines edges, and parallel_group nodes share a concurrency key. Log the full DAG, validation results, and any re-prompt events for debugging and audit trails.

Failure modes to instrument: The most common production failure is a dependency that the orchestrator cannot resolve because a sub-task output shape doesn't match what a downstream task expects. Mitigate this by pairing the dependency mapping prompt with the Input/Output Contract Definition Prompt—validate that every output_schema in the DAG satisfies the input_schema of its dependents before execution. A second failure mode is stale plans: if a sub-task fails mid-graph and requires re-decomposition, do not reuse the original DAG. Instead, call the Dynamic Re-Decomposition Prompt and regenerate the dependency map from the failure point forward, preserving completed sub-task outputs as fixed inputs. Finally, always set a global timeout on the full graph execution and define escalation behavior if the DAG cannot complete within the latency budget.

Model choice and cost considerations: Dependency mapping is a reasoning-heavy task that benefits from frontier models with strong structured output capabilities. Use a model that supports strict JSON mode or tool calling to enforce the DAG schema. Cache the prompt prefix containing the decomposition format and output schema to reduce per-call latency and cost. For high-throughput systems, consider routing simple linear dependency chains to a smaller model and reserving the full prompt for complex graphs with parallelization opportunities. Always log the model version, prompt hash, and validation pass/fail status to track plan quality over time.

IMPLEMENTATION TABLE

Expected Output Contract

Validation rules and format requirements for the directed acyclic graph produced by the Sub-Task Dependency Mapping prompt. Use this contract to build automated acceptance checks before passing the DAG to an orchestrator.

Field or ElementType or FormatRequiredValidation Rule

dag

object

Top-level object must contain nodes array and edges array

nodes

array of objects

Array length must be >= 1; each node must have a unique id field

nodes[].id

string

Must match pattern ^[a-z0-9_-]+$; no duplicate ids across the array

nodes[].label

string

Non-empty string; max 120 characters; must match [TASK_NAME] from input

nodes[].agent_role

string

If present, must match a role defined in [AGENT_POOL] input

edges

array of objects

Array length must be >= 0; each edge must reference valid node ids

edges[].source

string

Must match an existing nodes[].id value

edges[].target

string

Must match an existing nodes[].id value; must not equal source

edges[].dependency_type

enum

Must be one of: data, trigger, approval, or conditional

edges[].data_contract

object

If dependency_type is data, must contain required_fields array and format string

parallel_groups

array of arrays

If present, each inner array must contain valid node ids with no internal edge dependencies

cycle_check

boolean

Must be true; orchestrator must verify no cycles exist via topological sort before acceptance

orphan_check

boolean

Must be true; every node must appear in at least one edge or be the single root node

blocking_conditions

array of objects

If present, each object must have node_id, condition string, and timeout_seconds integer

PRACTICAL GUARDRAILS

Common Failure Modes

Dependency mapping fails silently in production when cycles, missing inputs, or orphaned tasks corrupt the execution plan. These are the most common failures and how to prevent them before dispatch.

01

Undetected Dependency Cycles

What to watch: The model produces a circular dependency where Task A depends on Task B and Task B depends on Task A, creating a deadlock that halts execution. This happens most often when tasks are named similarly or share overlapping responsibilities. Guardrail: Run a topological sort validator on every generated DAG before dispatch. Reject any plan that fails to produce a valid linear ordering. Include an explicit cycle-check instruction in the prompt: 'Verify that no task depends on itself, directly or transitively.'

02

Missing Input Artifacts

What to watch: A downstream task declares a dependency on an output that no upstream task produces. The orchestrator waits indefinitely or fails with an opaque 'missing input' error. This occurs when the model hallucinates artifact names or renames outputs between tasks. Guardrail: Extract every declared input and output artifact name from the generated plan. Cross-reference inputs against outputs. Flag any input with no matching producer. Add a prompt constraint: 'Every input artifact must be produced by exactly one upstream task.'

03

Orphaned Tasks with No Consumers

What to watch: A task produces an output that no downstream task consumes and that does not contribute to any final deliverable. The task wastes compute and may produce side effects that conflict with other work. Guardrail: Trace every task's output forward to a final consumer or end-state artifact. Flag tasks with zero downstream dependents that are not marked as terminal outputs. Add a prompt rule: 'Every task must either produce a required final output or feed at least one downstream task.'

04

Implicit Data Dependencies Omitted

What to watch: Two tasks share a resource, state, or side effect that the model does not declare as an explicit dependency. Task B starts before Task A finishes writing to a shared store, producing a race condition. Guardrail: Require the prompt to ask: 'Identify any shared resources, mutable state, or side effects between tasks and declare them as explicit dependencies.' Validate that every shared write has a corresponding read dependency. Flag tasks that write to the same resource without ordering constraints.

05

Over-Serialization of Independent Work

What to watch: The model inserts unnecessary sequential dependencies between tasks that could run in parallel, inflating end-to-end latency. This happens when the model defaults to linear chains instead of analyzing true independence. Guardrail: After generating the plan, run a parallelization analysis that identifies every pair of tasks with no data dependency. Flag any sequential ordering between independent tasks. Add a prompt instruction: 'Maximize parallel execution. Only add dependencies when a task genuinely requires another task's output.'

06

Stale Dependency After Re-Decomposition

What to watch: When a failed sub-task is re-decomposed, the new plan references artifacts or task IDs from the original failed plan that no longer exist. Downstream tasks wait for outputs that will never arrive. Guardrail: After any re-decomposition, run a full dependency integrity check that verifies every referenced task ID and artifact name exists in the current plan. Reject plans with dangling references. Include a prompt rule: 'Use only task IDs and artifact names defined in this plan. Do not reference outputs from prior failed attempts.'

IMPLEMENTATION TABLE

Evaluation Rubric

How to test output quality before shipping the Sub-Task Dependency Mapping prompt to production. Each criterion targets a specific failure mode in dependency graph generation.

CriterionPass StandardFailure SignalTest Method

Graph Completeness

Every sub-task from [TASK_LIST] appears as a node in the output graph

Orphaned tasks: a sub-task exists in the input but is missing from the dependency graph

Diff the set of task IDs in [TASK_LIST] against node IDs in the output graph; flag any missing

Cycle Detection

Output graph contains zero cycles; all dependency edges form a valid DAG

Cycle present: Task A depends on Task B which depends on Task A, or longer circular chains

Run topological sort on the output graph; if sort fails, a cycle exists and the output fails

Dependency Validity

Every dependency edge references task IDs that exist in [TASK_LIST] and the graph

Dangling reference: an edge points to a task ID not present in the input or graph nodes

Validate all depends_on values against the set of valid task IDs; flag any unmatched references

Data Contract Consistency

For every edge A->B, the output type of A matches or is compatible with the input type B expects

Type mismatch: Task A outputs string but Task B requires array with no transformation noted

Check declared output types against required input types for each dependency pair; flag incompatibilities

Parallelization Correctness

Tasks marked as parallelizable share no direct or transitive dependencies

False parallel group: two tasks in the same parallel group have a dependency edge between them

For each parallel group, verify no dependency path exists between any two members; flag violations

Blocking Condition Clarity

Every blocking dependency includes a specific condition that must be met before the dependent task can start

Vague blocker: dependency states 'Task A must complete' without specifying what output field or status signals readiness

Scan each edge for a blocking condition field; flag any that are empty, null, or contain only generic completion language

Critical Path Identification

Output identifies at least one critical path and its total estimated duration matches the sum of sequential tasks on that path

Missing or incorrect critical path: no path flagged, or duration doesn't match the longest dependency chain

Compute all paths through the DAG, verify the longest path is marked as critical, and check its duration estimate against the sum of task estimates on that path

Schema Compliance

Output matches the [OUTPUT_SCHEMA] exactly: all required fields present, no extra fields, correct types

Schema violation: missing nodes array, edges use wrong field names, or extra undeclared fields appear

Validate output against [OUTPUT_SCHEMA] with a JSON Schema validator; reject on any error

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Wrap the prompt in a pipeline: (1) validate [TASK_LIST] schema before prompting, (2) run the dependency mapping prompt, (3) programmatically check the output DAG for cycles using a graph library, (4) verify every depends_on task exists in the task list, (5) flag orphaned tasks with no consumers. Add retry logic with a repair prompt if validation fails. Log the DAG version for traceability.

Watch for

  • Silent format drift in the output DAG structure across model versions
  • Missing blocking conditions when a task can start with partial upstream output
  • Over-decomposition where the DAG becomes too fine-grained to execute efficiently
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.