Inferensys

Prompt

Parallel Tool Call Planning Few-Shot Prompt

A practical prompt playbook for using Parallel Tool Call Planning Few-Shot Prompt in production AI workflows to reduce agent latency by identifying independent tool calls and grouping them for parallel execution.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Parallel Tool Call Planning Few-Shot Prompt.

This prompt is designed for agent developers and AI engineers who need to reduce end-to-end latency in multi-tool workflows. The core job-to-be-done is teaching a model to analyze a set of available tools and a user's complex intent, then output a plan that groups independent tool calls for parallel execution. The ideal user is someone building a production agent where sequential tool calling creates unacceptable wait times for users, such as in customer-facing copilots or real-time data enrichment pipelines. Required context includes a complete list of available tool schemas, the user's objective, and any known dependencies between tools.

Use this prompt when you have a mature agent with 3+ tools and you've already solved basic tool selection and argument construction. It is most effective when latency profiling shows that sequential execution is the primary bottleneck, not model inference time. Do not use this prompt if your tool set changes dynamically per session without clear dependency documentation, as the few-shot examples will teach stale dependency assumptions. It is also inappropriate for workflows where all tool calls are inherently sequential—for example, a call that requires the output of a previous call as an input—as parallel planning adds unnecessary complexity and risks race conditions. The prompt assumes the model can reason about data dependencies, not just semantic similarity, so it requires a capable frontier model.

Before implementing this prompt, ensure you have a validation harness that can detect false dependencies (marking calls as sequential when they are independent) and missed parallelization opportunities (executing independent calls one by one). The next step is to pair this planning prompt with an execution runtime that respects the parallel groups and handles partial failures without deadlocking. Avoid using this prompt as a standalone solution; it must be integrated into an agent loop where the plan is parsed, validated, and executed with observability into which calls actually ran in parallel.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and the operational conditions required for safe deployment.

01

Good Fit: Multi-Tool Agent Orchestration

Use when: You have 3+ independent tools and need to reduce end-to-end latency by identifying non-dependent calls. Guardrail: Validate that the model's dependency graph matches your actual API constraints before executing parallel calls.

02

Bad Fit: Stateful Sequential Workflows

Avoid when: Each step's output is a required input for the next step, with no branching or independence. Guardrail: Fall back to a sequential execution plan if the dependency analysis returns a single chain with no parallelization opportunities.

03

Required Input: Tool Schemas with Side Effects

What to watch: The model cannot infer side effects or race conditions from function signatures alone. Guardrail: Annotate each tool definition with readOnly: true/false and idempotent: true/false so the prompt has the metadata needed to avoid unsafe parallel writes.

04

Required Input: Explicit Dependency Hints

What to watch: Models often hallucinate dependencies between tools that share similar names or entities. Guardrail: Include a dependsOn: [toolName] field in your tool definitions or provide few-shot examples that show correct independence judgments for tools with overlapping domains.

05

Operational Risk: Race Conditions on Shared State

Risk: Two parallel calls may read-modify-write the same resource, producing incorrect results. Guardrail: Implement a resource-locking check in your execution harness. If two tools target the same resource ID, serialize them regardless of the model's plan.

06

Operational Risk: Missed Parallelization Opportunities

Risk: The model serializes calls that are actually independent, increasing latency and degrading user experience. Guardrail: Run a post-hoc static analysis on the execution plan. Flag any serialized calls with no data dependency and log them for prompt improvement.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable few-shot prompt for planning parallel tool calls by analyzing dependencies and grouping independent operations.

This prompt template teaches the model to analyze a set of available tools and a user's request, then output a dependency graph and an execution plan that maximizes parallel execution. It uses few-shot examples to demonstrate the difference between true data dependencies (where one call's output is required as another's input) and false dependencies (where calls appear related but can execute independently). The template is designed for agent systems where reducing end-to-end latency is critical, such as multi-source research agents, data aggregation pipelines, and complex workflow orchestrators.

text
You are a tool-call planning assistant. Your job is to analyze a user request and a set of available tools, then produce a parallel execution plan that minimizes total latency while respecting true data dependencies.

## AVAILABLE TOOLS
[TOOLS]

## USER REQUEST
[INPUT]

## INSTRUCTIONS
1. Identify every tool call required to fulfill the user request.
2. For each tool call, determine its required inputs and whether those inputs depend on the output of any other tool call.
3. Classify dependencies as:
   - **HARD**: The output of call A is a required input for call B. B must wait for A.
   - **NONE**: The calls share no data dependency and can execute in parallel.
4. Group tool calls into execution waves, where all calls within a wave can run simultaneously.
5. For each tool call, specify the exact arguments using only information available at that wave (from the user request or from completed prior waves).
6. Flag any potential race conditions where parallel calls might conflict (e.g., writes to the same resource).

## OUTPUT FORMAT
Return a JSON object with this exact structure:
[OUTPUT_SCHEMA]

## CONSTRAINTS
[CONSTRAINTS]

## EXAMPLES

### Example 1: Independent Calls
**User Request:** "Get the weather for Tokyo and the latest news about AI."
**Available Tools:** get_weather(city: string), search_news(query: string)

**Analysis:**
- Call A: get_weather(city="Tokyo") — no dependencies
- Call B: search_news(query="AI") — no dependencies
- Dependency: NONE between A and B

**Plan:**
```json
{
  "waves": [
    {
      "wave_id": 1,
      "parallel_calls": [
        {"tool": "get_weather", "arguments": {"city": "Tokyo"}, "call_id": "A"},
        {"tool": "search_news", "arguments": {"query": "AI"}, "call_id": "B"}
      ]
    }
  ],
  "dependency_graph": {"A": [], "B": []},
  "race_condition_risks": []
}

Example 2: Sequential Dependency

User Request: "Find the capital of France, then get the weather there." Available Tools: get_capital(country: string), get_weather(city: string)

Analysis:

  • Call A: get_capital(country="France") — no dependencies
  • Call B: get_weather(city=<output of A>) — HARD dependency on A
  • Dependency: B depends on A

Plan:

json
{
  "waves": [
    {
      "wave_id": 1,
      "parallel_calls": [
        {"tool": "get_capital", "arguments": {"country": "France"}, "call_id": "A"}
      ]
    },
    {
      "wave_id": 2,
      "parallel_calls": [
        {"tool": "get_weather", "arguments": {"city": "$A.capital"}, "call_id": "B"}
      ]
    }
  ],
  "dependency_graph": {"A": [], "B": ["A"]},
  "race_condition_risks": []
}

Example 3: False Dependency Detection

User Request: "Get stock prices for AAPL and MSFT, and also get the latest news about AAPL." Available Tools: get_stock_price(symbol: string), search_news(query: string)

Analysis:

  • Call A: get_stock_price(symbol="AAPL") — no dependencies
  • Call B: get_stock_price(symbol="MSFT") — no dependencies
  • Call C: search_news(query="AAPL") — no dependencies (does NOT require call A's output)
  • Dependency: NONE among A, B, C — all three can run in parallel despite sharing the ticker "AAPL"

Plan:

json
{
  "waves": [
    {
      "wave_id": 1,
      "parallel_calls": [
        {"tool": "get_stock_price", "arguments": {"symbol": "AAPL"}, "call_id": "A"},
        {"tool": "get_stock_price", "arguments": {"symbol": "MSFT"}, "call_id": "B"},
        {"tool": "search_news", "arguments": {"query": "AAPL"}, "call_id": "C"}
      ]
    }
  ],
  "dependency_graph": {"A": [], "B": [], "C": []},
  "race_condition_risks": []
}

[EXAMPLES]

RISK LEVEL

[RISK_LEVEL]

Now analyze the user request and produce the parallel execution plan.

To adapt this template, replace the square-bracket placeholders with your specific context. The [TOOLS] placeholder should contain your tool definitions in a structured format (OpenAPI, JSON Schema, or a simple name-and-parameters list). The [OUTPUT_SCHEMA] should define the exact JSON structure your execution harness expects, including fields for waves, dependency_graph, and race_condition_risks. The [EXAMPLES] placeholder is where you add domain-specific scenarios that reflect your actual tool set and common user requests—these are the most critical element because they teach the model to distinguish true data dependencies from coincidental parameter overlap. The [CONSTRAINTS] field should specify limits like maximum parallel calls per wave, timeout assumptions, or idempotency requirements for write operations. For high-risk workflows where parallel execution could cause data corruption (e.g., concurrent database writes), set [RISK_LEVEL] to "high" and add explicit instructions requiring human review of the plan before execution.

Before deploying this prompt, validate it against a test suite that includes: requests where all calls are independent (should produce a single wave), requests with a clear linear dependency chain (should produce sequential waves), and requests with false dependencies (should correctly identify parallelism opportunities). Common failure modes include the model serializing calls that share a topic but not data, failing to propagate intermediate results between waves, and missing race conditions when parallel calls target the same mutable resource. Run these test cases through your eval harness and measure both plan correctness and the achieved parallelism ratio (independent calls executed in parallel divided by total independent calls). If the model consistently misses parallelization opportunities, add more false-dependency examples to the [EXAMPLES] section. If it creates unsafe parallel plans, strengthen the [CONSTRAINTS] and add negative examples showing rejected plans with race conditions.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the parallel tool call planning few-shot prompt. Each variable must be populated before the prompt is assembled and sent to the model.

PlaceholderPurposeExampleValidation Notes

[TOOL_DEFINITIONS]

JSON array of available tool schemas with names, descriptions, and parameter specs

[{"name": "search_products", "description": "Search product catalog by keyword", "parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]}}]

Validate JSON schema compliance. Each tool must have name, description, and parameters fields. Empty array allowed but will produce no tool calls.

[USER_QUERY]

Natural language request that may require multiple tool calls to fulfill

"Find me the top-rated wireless headphones under $100 and check if they're in stock at my nearest store"

Non-empty string required. Max length should match model context window minus prompt overhead. Check for ambiguous entity references that need resolution before planning.

[FEW_SHOT_EXAMPLES]

Array of input-output pairs demonstrating parallel vs sequential tool call decisions with dependency reasoning

[{"input": "...", "output": {"parallel_calls": [...], "sequential_calls": [...], "reasoning": "..."}}]

Minimum 3 examples covering: independent calls, true dependencies, and false dependencies. Validate each example has explicit dependency reasoning. Examples must match current [TOOL_DEFINITIONS] or use generic patterns.

[DEPENDENCY_RULES]

Explicit rules for determining when one tool call depends on another's output

["Tool B depends on Tool A if B's required parameters include fields only produced by A's output schema", "Calls are independent if they share no parameter-to-output dependencies"]

At least one rule required. Rules must reference concrete output-to-parameter mappings. Vague rules produce inconsistent parallelization. Test rules against [FEW_SHOT_EXAMPLES] for consistency.

[MAX_PARALLEL_CALLS]

Upper limit on simultaneous tool calls the system can execute

5

Positive integer. Must match actual system concurrency limits. Setting higher than system capability causes queue blocking. Setting lower misses optimization opportunities. Validate against deployment configuration.

[OUTPUT_FORMAT]

Expected JSON structure for the planning output including parallel_groups and sequential_steps

{"parallel_groups": [["tool_call_1", "tool_call_2"]], "sequential_steps": ["tool_call_3"], "dependency_graph": {...}}

Validate against JSON Schema. Must include fields for parallel groups, sequential steps, and dependency justification. Missing dependency_graph field prevents auditability of planning decisions.

[RACE_CONDITION_FLAGS]

Optional list of known unsafe parallel combinations that must be serialized even if they appear independent

["update_inventory + create_order: inventory must reflect pending orders before confirmation"]

Null allowed if no known race conditions. When provided, each entry must name specific tool pairs and explain the conflict. Test that [FEW_SHOT_EXAMPLES] respect these flags.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the parallel tool call planning prompt into an agent runtime with validation, retries, and dependency-aware execution.

This prompt is designed to sit between the agent's planning step and its tool execution layer. It receives a task description and a list of available tool signatures, then outputs a dependency graph and parallel execution groups. The harness must parse this structured output and feed it into an executor that respects the declared dependencies. Do not treat this prompt as a black box that directly invokes tools—its job is to produce a plan, and the harness is responsible for enforcing that plan's constraints at runtime.

The integration flow should follow a strict sequence: (1) assemble the prompt with the current task, available tool list, and few-shot examples; (2) call the model with a low temperature (0.0–0.2) and a structured output mode targeting your dependency graph schema; (3) validate the output against a schema that requires each tool call to declare its dependencies as an array of tool call IDs, and reject any plan where a dependency references a non-existent ID or creates a cycle; (4) execute the plan using a directed acyclic graph (DAG) executor that runs independent groups in parallel and serializes dependent calls; (5) if any tool call fails, re-invoke the planning prompt with the failure context and remaining task to generate a revised plan. Log every plan, its validation result, and any runtime dependency violations for debugging false dependencies or missed parallelization opportunities.

For production deployments, add a parallelism cap in the executor (e.g., max 5 concurrent calls) to avoid overwhelming downstream APIs, even if the plan suggests more. Implement a race condition detector that flags when two supposedly independent calls write to the same resource or mutate shared state—this is a common failure mode where the prompt's dependency analysis is correct for data flow but wrong for side effects. Include an eval harness that compares the generated plan against a golden set of known parallelizable and dependent tool call scenarios, measuring precision and recall on dependency edge detection. When the prompt misses a parallelization opportunity, log the case for few-shot example updates. When it creates a false dependency, trace whether the model confused data ordering with logical dependency. Finally, gate any plan that proposes more than [MAX_TOOL_CALLS] total invocations and route it to a human reviewer or a decomposition prompt to split the task further.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required structure for the model's parallel execution plan. Use this contract to validate the output before passing it to an orchestrator.

Field or ElementType or FormatRequiredValidation Rule

execution_groups

Array of arrays of ToolCall objects

Top-level key must exist. Must be an array. Empty array is valid only if no tools are needed.

execution_groups[i]

Array of ToolCall objects

Each element must be a non-empty array representing a group of calls that can run in parallel.

execution_groups[i][j].tool_name

String

Must match a tool name exactly from the provided [TOOL_LIST]. No hallucinated tool names allowed.

execution_groups[i][j].arguments

Object

Must be a valid JSON object. Keys and value types must match the target tool's schema in [TOOL_SCHEMAS].

execution_groups[i][j].reasoning

String

If present, must be a non-empty string explaining why the tool call is placed in this group. Null allowed.

dependency_analysis

Array of Dependency objects

Must be an array. Each object must have 'dependent' and 'depends_on' fields referencing tool call IDs.

dependency_analysis[i].dependent

String

Must be a unique ID assigned to a tool call within the plan. Must match the 'call_id' of exactly one tool call.

dependency_analysis[i].depends_on

String

Must be a unique ID of another tool call whose output is required. Must not create a circular dependency.

PRACTICAL GUARDRAILS

Common Failure Modes

Parallel tool call planning reduces latency but introduces dependency, ordering, and race condition risks. These are the most common failures and how to prevent them.

01

False Independence

What to watch: The model groups calls as parallel when one call's output is a required input for another. This causes the dependent call to fail or hallucinate arguments. Guardrail: Include few-shot examples that explicitly mark data dependencies with a depends_on field and validate the execution plan against tool input schemas before dispatch.

02

Missed Parallelization Opportunities

What to watch: The model executes independent calls sequentially out of caution, increasing end-to-end latency and wasting token budget on unnecessary wait steps. Guardrail: Add a post-processing check that scans the planned sequence for calls with no shared inputs and flags them for parallel execution. Use few-shot examples showing aggressive but safe grouping.

03

Race Condition on Shared Mutable State

What to watch: Two parallel calls read and write the same resource, producing inconsistent results. Common with database updates, file writes, or cache modifications. Guardrail: Define tool contracts that mark side effects explicitly. In few-shot examples, show the model refusing to parallelize calls that target the same mutable resource and instead sequencing them.

04

Argument Hallucination Under Parallel Pressure

What to watch: When planning multiple calls at once, the model invents IDs, dates, or entity values to fill arguments it cannot yet resolve, especially for later calls in the batch. Guardrail: Validate all tool arguments against the source context before execution. Include negative examples showing hallucinated arguments being caught and corrected with a clarification request.

05

Partial Failure Cascades

What to watch: One parallel call fails, but dependent sequential calls proceed with stale or null inputs from the failed branch, producing garbage outputs silently. Guardrail: Implement a dependency-aware abort. If a call fails, cancel all downstream dependents. Few-shot examples should demonstrate checking each parallel result before proceeding to the next dependency layer.

06

Tool Overload and Rate Limit Burst

What to watch: The model correctly identifies 10+ independent calls and dispatches them simultaneously, hitting API rate limits or overwhelming a local resource. Guardrail: Add a max_parallel_calls constraint in the system prompt. Show examples where the model batches calls into groups of 3-5 with brief delays, respecting documented tool rate limits.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test whether the few-shot parallel tool call planning prompt produces correct dependency analysis and grouping before shipping to production.

CriterionPass StandardFailure SignalTest Method

Dependency Detection Accuracy

All true dependencies identified; no false dependencies flagged

Sequential ordering forced between independent calls; parallelizable calls blocked by phantom dependency

Run 20 curated test cases with known dependency graphs; compare predicted vs. ground-truth dependency edges

Parallel Grouping Correctness

All independent calls grouped into same parallel batch; dependent calls placed in correct sequential order after prerequisites

Independent calls split across multiple sequential steps; dependent call placed before its prerequisite completes

Parse output grouping structure; verify each group contains only mutually independent calls; check prerequisite ordering

Tool Argument Completeness

All required arguments present for every tool call; no argument values depend on uncompleted parallel calls

Missing required field in tool call; argument references output of call in same parallel group

Schema-validate each tool call against its function definition; check for cross-call argument dependencies within same group

Race Condition Avoidance

No shared mutable resource modified by parallel calls without explicit ordering constraint

Two parallel calls write to same resource; read-modify-write sequence split across parallel groups

Audit tool descriptions for shared resource indicators; verify write conflicts are serialized in output plan

Missed Parallelization Detection

All parallelizable opportunities identified; no independent calls left sequential without justification

Two calls with no data dependency placed in sequential order; latency-optimal plan not achieved

Compare output grouping to optimal parallel plan; measure parallelization ratio (independent calls grouped / total parallelizable calls)

Plan Completeness

All required tool calls from user intent included in plan; no omitted necessary steps

Missing tool call that user request implies; incomplete workflow that would fail at runtime

Map user intent to expected tool call set; verify all expected calls present in output plan

Hallucinated Tool Prevention

No fabricated tool names, parameter values, or dependency relationships not grounded in input

Invented tool name not in available tool list; made-up entity ID passed as argument; phantom dependency on non-existent call

Cross-reference all tool names against provided tool list; verify all argument values trace to user input or prior call outputs

Edge Case Handling

Correct behavior on empty tool list, single tool, fully sequential chains, and fully parallel sets

Error or nonsensical output on boundary inputs; unnecessary sequential ordering when only one tool available

Test with edge case inputs: 0 tools, 1 tool, all-dependent chain, all-independent set; verify output structure remains valid

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base few-shot prompt and a small set of 3-4 tools. Use inline examples that show dependency analysis and parallel grouping for independent calls. Keep the output schema loose—accept a simple JSON array of call groups.

code
[SYSTEM]
You are a tool-call planner. Given a user request and available tools, identify which calls can run in parallel and which must run sequentially. Group independent calls together.

[EXAMPLES]
User: "Get the weather in SF and NYC, then summarize both."
Tools: [get_weather, summarize_text]
Plan:
[
  {"parallel_group": 1, "calls": [
    {"tool": "get_weather", "args": {"city": "San Francisco"}},
    {"tool": "get_weather", "args": {"city": "New York"}}
  ]},
  {"parallel_group": 2, "calls": [
    {"tool": "summarize_text", "args": {"text": "[RESULT_FROM_GROUP_1]"}}
  ]}
]

[USER REQUEST]
[INPUT]

[AVAILABLE TOOLS]
[TOOL_LIST]

Watch for

  • Missing dependency detection when one tool's output is another's input
  • Overly broad parallel groups that include dependent calls
  • No validation of tool argument schemas
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.