This prompt is for integration developers and agent infrastructure engineers who need to pass structured state through a chain of dependent tool calls. Instead of dumping raw tool outputs into the next call, this prompt produces a context mapping specification that defines exactly which fields from each tool output flow into subsequent tool inputs, what transformations apply, what default values to use when fields are missing, and how much of the context window each step consumes. Use this when you have three or more tools that must execute in a strict sequence because later tools depend on earlier results, and you need the mapping to be auditable, debuggable, and budget-aware.
Prompt
Sequential Context Propagation Prompt for Multi-Tool Flows

When to Use This Prompt
Identifies the integration scenarios, user profiles, and system constraints where a sequential context propagation specification is the right solution, and when simpler alternatives should be used instead.
The ideal user is building a production agent or integration pipeline where tool call ordering is non-negotiable—for example, a customer support agent that must first look up an account, then retrieve recent orders, then check inventory for those orders, and finally generate a response. Each step consumes fields from the previous step's output. Without an explicit mapping specification, the model may hallucinate field names, pass entire raw payloads that blow the context window, or silently drop required fields. This prompt forces the model to produce a machine-readable mapping that your orchestrator can validate before execution begins. Do not use this prompt when you have only one or two tools, when tools are fully independent and can run in parallel, or when your orchestrator already has a hardcoded field-mapping layer. In those cases, a simpler parallel-execution prompt or a static mapping configuration is more appropriate and cheaper to run.
The prompt also includes context window budget tracking, which is critical for long chains. Each step's mapping specification declares how many tokens of the previous output are retained and passed forward. This lets you catch budget overruns at plan time rather than mid-execution when the model loses context. The output is designed to be consumed by an execution engine that reads the mapping, extracts the specified fields, applies transformations, and injects only the required context into each subsequent tool call. Before adopting this prompt, confirm that your orchestrator can consume a structured mapping specification and enforce field-level context injection. If your system passes entire message histories between calls, this prompt will add overhead without benefit. Start with a three-tool chain where you can manually verify the mapping correctness, then expand to longer sequences once the validation loop is stable.
Use Case Fit
Where the Sequential Context Propagation Prompt delivers reliable multi-tool orchestration and where it introduces fragility. Use this playbook when state must flow through a chain of dependent tool calls.
Good Fit: Strictly Ordered Data Pipelines
Use when: Each tool call consumes the output of a previous call and the dependency graph is a clear, linear chain or a simple DAG. Guardrail: Validate that every input field in a downstream tool is explicitly mapped from an upstream output field in the prompt's context mapping specification.
Bad Fit: Independent Parallel Fetches
Avoid when: The tools can be called in any order without data dependencies. Risk: Forcing a sequential prompt on parallel-safe calls adds unnecessary latency and consumes extra context window budget. Guardrail: Use a Parallel vs Sequential Decision Prompt first to classify the execution plan.
Required Input: Explicit Tool Schemas
What to watch: The prompt cannot propagate context accurately if it must guess tool input signatures. Guardrail: Provide the full JSON schema for every tool in the chain, including required fields, types, and descriptions, so the model can generate a precise field-level mapping.
Operational Risk: Context Window Exhaustion
Risk: Accumulating raw outputs from every step in a long chain can silently exceed the model's context limit, causing mid-sequence truncation. Guardrail: Implement context budget tracking. Instruct the prompt to summarize or drop intermediate outputs once their required fields have been extracted and propagated.
Operational Risk: Stale or Missing Intermediate Data
Risk: An upstream tool call returns an empty result or omits a field that a downstream tool requires, breaking the entire sequence. Guardrail: Define default values and fallback behaviors for every mapped field in the prompt's transformation rules. If a critical field is missing, the plan should halt and escalate.
Bad Fit: High-Branching Agentic Workflows
Avoid when: The next tool choice depends on the semantic meaning of the previous result, not just its structured data. Risk: A static context propagation map cannot handle dynamic tool selection. Guardrail: Use an Agent Planning and Task Decomposition prompt for dynamic paths, and reserve this playbook for deterministic data-flow chains.
Copy-Ready Prompt Template
A reusable prompt template that maps tool outputs to subsequent tool inputs across a multi-step sequence, including transformation rules and context budget tracking.
This prompt template is designed to be inserted into a multi-turn agent loop after a set of tool calls has been executed. Its job is to produce a precise context mapping specification: for each pending tool call in a sequence, it identifies which fields from previous tool outputs should flow into the current tool's arguments, how those values should be transformed, and what defaults apply when upstream data is missing. The output is a machine-readable specification that your orchestrator can use to construct the next tool call payload without hallucinating dependencies or dropping required context.
codeYou are a context propagation planner for a multi-tool execution engine. Your task is to produce a context mapping specification that determines how outputs from previously executed tool calls flow into the inputs of the next tool call in a sequence. # PREVIOUS TOOL OUTPUTS [PREVIOUS_OUTPUTS] # PENDING TOOL CALL Tool Name: [TOOL_NAME] Tool Description: [TOOL_DESCRIPTION] Tool Parameter Schema: [TOOL_SCHEMA] # EXECUTION CONTEXT Overall Task: [TASK_DESCRIPTION] User Identity: [USER_CONTEXT] Session Data: [SESSION_CONTEXT] # CONSTRAINTS - Context Window Budget Remaining: [TOKEN_BUDGET] tokens - Maximum fields per mapping: [MAX_FIELDS] - Required fields that MUST be populated: [REQUIRED_FIELDS] - Forbidden data sources (do not reference): [FORBIDDEN_SOURCES] - Risk Level: [RISK_LEVEL] # OUTPUT SCHEMA Return a JSON object with the following structure: { "tool_name": "string", "mappings": [ { "target_parameter": "string (parameter name in pending tool schema)", "source": { "tool_call_id": "string (id of previous tool call)", "output_path": "string (JSONPath or dot-notation to field)" }, "transformation": "string (none | extract | format | map | filter | aggregate | compute)", "transformation_rule": "string (human-readable rule, or null if none)", "default_value": "any (value to use if source is missing or null)", "required": true/false } ], "unresolved_parameters": ["string (parameters with no available source)"], "context_window_used": "number (estimated tokens consumed by mapped values)", "warnings": ["string (missing data, type mismatches, budget overruns)"], "propagation_notes": "string (explanation of mapping decisions)" } # RULES 1. Only map fields that exist in [PREVIOUS_OUTPUTS]. Do not invent data. 2. If a required field has no available source, list it in unresolved_parameters and set its default_value to null. 3. For transformation "extract", specify which substring or element to pull. 4. For transformation "map", specify the value mapping table (e.g., "open" -> "active"). 5. For transformation "aggregate", specify the aggregation function (sum, count, concat, merge). 6. If context_window_used exceeds [TOKEN_BUDGET], include a warning and suggest field pruning. 7. If [RISK_LEVEL] is "high", add a human_review_required flag to any mapping involving financial, PII, or state-mutating data. 8. Do not propagate fields from [FORBIDDEN_SOURCES]. 9. If a source field contains a list and the target expects a scalar, specify the selection rule in transformation_rule. 10. Preserve data types. If a type mismatch exists, note it in warnings and apply a safe coercion rule.
To adapt this template, replace each square-bracket placeholder with values from your execution context. [PREVIOUS_OUTPUTS] should contain the full JSON response bodies from all completed tool calls, keyed by tool call ID. [TOOL_SCHEMA] should be the exact JSON Schema or function definition for the pending tool. The [TOKEN_BUDGET] field is critical for long sequences—track cumulative context usage across steps and reduce the budget for later calls. For high-risk workflows, set [RISK_LEVEL] to "high" and ensure your orchestrator respects the human_review_required flag before executing the next tool call. Test this prompt with at least three scenarios: a clean sequence where all dependencies resolve, a sequence with missing upstream data, and a sequence that exceeds the token budget.
Prompt Variables
Required inputs for the Sequential Context Propagation Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to check that the input is well-formed and safe.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TOOL_CALL_SEQUENCE] | Ordered list of tool calls with their input schemas and expected output schemas | Step 1: search_documents(query, filters) -> {doc_ids, snippets}; Step 2: fetch_full_text(doc_ids) -> {documents} | Parse check: must be a valid JSON array of step objects. Each step requires a tool name, input schema, and output schema. Null not allowed. |
[CURRENT_STATE] | Accumulated context from previously executed steps in the sequence | {"step_1": {"doc_ids": ["doc_123", "doc_456"], "snippets": ["..."]}} | Schema check: must be a valid JSON object keyed by step identifier. May be empty object for first step. Null allowed if no prior steps executed. |
[TARGET_STEP_INDEX] | Zero-based index of the step currently being prepared for execution | 2 | Parse check: must be a non-negative integer. Must be less than the length of [TOOL_CALL_SEQUENCE]. Null not allowed. |
[CONTEXT_WINDOW_BUDGET] | Maximum token budget available for context propagation in the current step | 4000 | Parse check: must be a positive integer. Should be derived from model context limit minus system prompt, tool schemas, and output reservation. Null not allowed. |
[REQUIRED_OUTPUT_FIELDS] | Fields from prior step outputs that the current step's input schema demands | ["step_1.doc_ids", "step_2.summary_text"] | Schema check: must be an array of dot-notation field paths. Each path must reference a field that exists in a prior step's output schema. Null allowed if current step has no upstream dependencies. |
[TRANSFORMATION_RULES] | Rules for reshaping prior outputs to match current step input schema | {"step_1.doc_ids": "pass-through", "step_2.summary_text": "truncate:500"} | Schema check: must be a JSON object mapping field paths to transformation directives. Supported directives: pass-through, truncate:N, default:VALUE, format:TEMPLATE. Null allowed if no transformations needed. |
[DEFAULT_VALUES] | Fallback values when required upstream fields are missing or null | {"filters.date_range": "last_30_days", "max_results": 10} | Schema check: must be a JSON object mapping field paths to default values. Each path must correspond to an optional field in the current step's input schema. Null allowed if all required fields are guaranteed present. |
[CONTEXT_PROPAGATION_MODE] | Strategy for packing propagated context: full, summarized, or selective | selective | Enum check: must be one of 'full', 'summarized', or 'selective'. 'full' passes all prior outputs. 'summarized' compresses prior outputs. 'selective' passes only [REQUIRED_OUTPUT_FIELDS]. Null not allowed. |
Implementation Harness Notes
How to wire the Sequential Context Propagation Prompt into a multi-tool agent loop with validation, retries, and context window tracking.
This prompt is designed to be called between tool execution steps in an agent loop, not as a one-shot planner. After a tool returns its output, the agent runtime should construct a new prompt call that includes the previous tool's output, the original user goal, and the list of remaining tools. The model's job is to produce a context mapping specification—a structured JSON object that defines exactly which fields from the prior output should be injected into the next tool's input, along with any transformation rules and default values. This mapping is then applied by the application layer before the next tool is invoked. Do not pass raw tool outputs directly to the next tool; the mapping specification is the contract that prevents stale, oversized, or incorrectly shaped context from propagating through the chain.
Wiring the loop: Your agent executor should maintain a context_budget counter (in tokens or characters) and a propagation_log array. Before each tool call, invoke this prompt with [PREVIOUS_TOOL_OUTPUT], [NEXT_TOOL_SCHEMA], [CONTEXT_BUDGET_REMAINING], and [USER_GOAL]. Parse the returned JSON mapping specification and validate it against the next tool's input schema before execution. If validation fails, retry the prompt once with the validation error included in [CONSTRAINTS]. If the mapping exceeds the remaining context budget, the prompt should return a budget_exceeded flag with a prioritized subset of fields; your harness must honor this and truncate accordingly. Log every mapping decision to the propagation_log for debugging and audit. For high-stakes workflows (finance, healthcare, legal), insert a human review gate when the mapping confidence score falls below 0.85 or when the prompt flags a needs_clarification status.
Model choice and failure modes: Use a model with strong structured output support (GPT-4o, Claude 3.5 Sonnet, or equivalent) and enable JSON mode or structured outputs. The most common production failure is the model hallucinating field names that don't exist in the next tool's schema—always validate the mapping against the actual tool input schema before execution. A secondary failure mode is the model propagating too much context, blowing the context window for later steps; the context_budget_remaining parameter is your primary defense. If the prompt returns a mapping that fails schema validation after one retry, abort the chain and escalate to a human operator with the full propagation_log. Do not silently drop fields or guess transformations in the application layer—the model's mapping is the auditable decision record.
Expected Output Contract
Defines the exact shape of the context mapping specification produced by the prompt. Use this contract to validate model output before passing it to the orchestration engine.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
context_map | Array of objects | Must be a non-empty JSON array. Parse check: valid JSON. Schema check: each element must match the field_map schema. | |
context_map[].source_tool | String | Must match a tool name from the [TOOL_REGISTRY] input. Regex check against allowed tool names. | |
context_map[].source_field | String (dot-notation path) | Must be a valid JSONPath expression within the source tool's output schema. Schema check against [TOOL_SCHEMAS]. | |
context_map[].target_tool | String | Must match a tool name from the [TOOL_REGISTRY] input. Must differ from source_tool. No self-referential mappings allowed. | |
context_map[].target_parameter | String | Must match a parameter name in the target tool's input schema. Schema check against [TOOL_SCHEMAS]. | |
context_map[].transformation | String or null | If present, must be one of: 'direct', 'stringify', 'parse_number', 'extract_first', 'template', or a custom expression starting with 'expr:'. Null allowed for direct passthrough. | |
context_map[].default_value | Any valid JSON or null | Must match the expected type of target_parameter. Type check against [TOOL_SCHEMAS]. Null allowed when field is optional. | |
context_window_budget | Object | Must contain 'total_tokens_estimated' (integer), 'per_step_budget' (array of objects with 'step' and 'tokens' fields), and 'overflow_strategy' (one of: 'truncate', 'summarize', 'abort'). |
Common Failure Modes
Context propagation chains break silently. These are the most common failure modes when passing state through sequential tool calls and how to prevent them before they corrupt downstream execution.
Silent Field Name Mismatch
What to watch: The model maps tool_A.output.user_id to tool_B.input.customerId but the actual output field is id. The chain proceeds with a null or default value, producing valid-looking but incorrect results. Guardrail: Include an explicit context mapping specification in the prompt with source and target field paths. Validate that every mapped field exists in the upstream output schema before execution.
Stale Intermediate Context
What to watch: A tool call in step 3 references output from step 1, but step 2 mutated the underlying resource. The propagated value is now stale and downstream decisions are based on invalid state. Guardrail: Annotate each propagated field with a freshness requirement. For read-after-write sequences, enforce that the read tool re-fetches rather than relying on propagated values. Add staleness bounds to the context mapping.
Context Window Budget Exhaustion
What to watch: Each tool output is appended in full to the context, and by step 4 the cumulative payload exceeds the model's effective attention window. The model silently ignores early context, losing critical upstream decisions. Guardrail: Define a field-level propagation budget. Only pass fields explicitly needed by downstream tools. Summarize or truncate verbose outputs. Track cumulative token usage and trigger a compaction step when approaching the budget limit.
Missing Intermediate Field on Partial Failure
What to watch: A tool returns a partial success but omits a field that a downstream tool requires. The propagation logic inserts a null, and the downstream tool either fails cryptically or executes with incomplete data. Guardrail: Define required vs. optional fields in the context mapping. When a required field is missing, halt the chain and escalate. For optional fields, specify explicit default values per field. Never propagate null silently into a required downstream input.
Type Coercion Drift Across Tool Boundaries
What to watch: Tool A outputs price as a string "$12.99", but Tool B expects a float 12.99. The model passes the string through, and the downstream tool rejects it or interprets it incorrectly. Guardrail: Include transformation rules in the context mapping specification. For each propagated field, declare the expected output type, the required input type, and the coercion or formatting rule. Validate types at each handoff point.
Over-Propagation of Sensitive Fields
What to watch: An upstream tool returns PII, internal identifiers, or raw data that downstream tools don't need. The model includes it in the propagated context, and it leaks into logs, audit trails, or user-facing responses. Guardrail: Define an explicit allowlist of propagatable fields. Strip all other fields before passing context to the next step. Add a pre-propagation redaction check for PII patterns, even in allowed fields.
Evaluation Rubric
Criteria for testing whether the context propagation specification is correct, complete, and safe before integrating into a production multi-tool execution engine.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Field mapping completeness | Every required input field for each downstream tool is mapped from an upstream output, a default, or a user-provided value | A downstream tool call fails validation due to a missing required argument | Schema diff: compare downstream tool input schemas against the generated [FIELD_MAP] to detect unmapped required fields |
Type compatibility | All mapped fields have compatible types between source output and target input, or include an explicit transformation rule | A downstream tool call receives a string where an integer is expected, causing a parse error | Type assertion test: run the [TRANSFORMATION_RULES] against sample upstream outputs and validate the resulting types match downstream input schemas |
Dependency ordering | The [EXECUTION_SEQUENCE] respects all declared dependencies; no tool is scheduled before its upstream dependencies complete | A tool call executes before its required input is available, resulting in null or stale data | Topological sort validation: parse the [DEPENDENCY_GRAPH], run a cycle detection algorithm, and verify the sequence is a valid topological ordering |
Default value safety | Every default value in [DEFAULT_VALUES] is valid for the target field's type, constraints, and business rules | A default value violates an enum constraint or produces a semantically invalid tool call | Schema validation: apply each default value to its target field and check against the tool's JSON Schema or equivalent constraint definition |
Context window budget adherence | The total estimated token count for all propagated context fields does not exceed the [CONTEXT_BUDGET] limit | The assembled context for a downstream call is truncated or the model request exceeds the context window | Token counting: serialize the propagated context payload for each step, count tokens with the target model's tokenizer, and assert total <= [CONTEXT_BUDGET] |
Transformation rule correctness | Each [TRANSFORMATION_RULE] produces the expected output type and value range when applied to representative upstream outputs | A transformation produces null, out-of-range, or incorrectly formatted values for valid upstream inputs | Unit test: apply each transformation rule to 5-10 sample upstream outputs and assert the result matches the expected downstream input |
Staleness handling | The specification includes a [STALENESS_BOUND] for each propagated field, and fields exceeding the bound are flagged or refreshed | A downstream tool call uses a cached value that is 30 minutes old when the bound is 5 minutes | Time-window simulation: inject upstream outputs with varying timestamps and verify the propagation logic respects the declared staleness bounds |
Missing upstream output handling | The specification defines behavior for every possible missing or null upstream field: skip, use default, abort, or request human input | A null upstream output propagates silently and causes an unhandled null pointer in the downstream tool call | Null injection test: for each mapped field, simulate a missing upstream output and verify the system follows the declared [MISSING_FIELD_POLICY] |
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
Add strict schema validation, context window budget tracking, and eval cases. Replace [TOOL_OUTPUT_SCHEMAS] with full JSON Schema definitions including required fields, types, and enums. Add a [CONTEXT_WINDOW_BUDGET] parameter that limits total propagated token count. Include 3–5 diverse [FEW_SHOT_EXAMPLES] covering happy path, missing optional fields, and type coercion scenarios. Add a [VALIDATION_RULES] section that the model must self-check before returning.
Prompt snippet
codeYou are building a validated context propagation map for a multi-tool chain. Tool output schemas (JSON Schema): [TOOL_OUTPUT_SCHEMAS] Context window budget: [CONTEXT_WINDOW_BUDGET] tokens Validation rules: [VALIDATION_RULES] Examples: [FEW_SHOT_EXAMPLES] For each tool after the first, produce: 1. Source field (tool_name.field_path) 2. Target field (tool_name.parameter_name) 3. Transformation rule (direct | rename | coerce | default) 4. Token estimate 5. Total propagated token count must not exceed budget Return as JSON with a "propagation_map" array and "budget_remaining" field.
Watch for
- Silent format drift where the model drops the "budget_remaining" field under load
- Type coercion rules that are described in prose but not executable
- Missing human review gate when propagation involves PII or sensitive fields

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