Inferensys

Prompt

Multi-Agent Handoff State Preservation Prompt

A practical prompt playbook for generating a structured handoff package that preserves task state, relevant history, unresolved dependencies, and authority boundaries when one agent passes execution context to another specialized agent.
Engineer reviewing agent handoff workflow on laptop, task routing diagrams visible, technical office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise conditions for using the multi-agent handoff prompt and warns against misapplication in single-agent or human-facing scenarios.

This prompt is designed for multi-agent orchestrators and framework developers who need a reliable, machine-readable handoff package when transferring work from one specialized agent to another. Use it when a generalist agent completes its scoped work and must pass partial results, open questions, and unresolved dependencies to a downstream specialist agent. The prompt produces a structured JSON payload that the receiving agent can consume without replaying the entire execution history.

Do not use this prompt for single-agent checkpointing, human-readable summaries, or cross-session resumption. Those scenarios require different state serialization patterns covered in sibling playbooks such as Agent State Snapshot or Human-in-the-Loop Handoff State. Using this prompt for human review will produce overly verbose, machine-optimized payloads that obscure decision rationale. Using it for intra-agent checkpointing will include unnecessary handoff metadata that bloats context windows without adding resumption value.

Before implementing this prompt, confirm that your system has at least two distinct agent roles with separate system prompts, tool sets, or authority boundaries. If a single agent can complete the entire workflow, use a checkpointing prompt instead. If the handoff requires human approval before the specialist agent proceeds, combine this prompt with the Human-in-the-Loop Handoff State prompt to produce both the machine-readable payload and a reviewer-ready summary. Always validate the handoff payload against the receiving agent's expected schema before passing control.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Multi-Agent Handoff State Preservation Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your agent topology before integrating it into a handoff protocol.

01

Strong Fit: Heterogeneous Agent Teams

Use when: A generalist planner hands work to a specialist code-writer, data-analyst, or reviewer agent. Guardrail: The handoff must include the original goal, completed steps, and unresolved dependencies so the specialist doesn't repeat work or operate on stale assumptions.

02

Poor Fit: Single-Agent Loops

Avoid when: One agent handles the entire task in a tight loop with no role transfer. Guardrail: Use a progress-tracking or checkpoint prompt instead. Adding a handoff layer here creates serialization overhead with no coordination benefit.

03

Required Inputs

What you need: The sending agent's task state, action history, tool outputs, pending decisions, and authority boundaries. Guardrail: If any of these are missing, the receiving agent will hallucinate context or duplicate work. Validate input completeness before calling the handoff prompt.

04

Operational Risk: Context Sufficiency

What to watch: The receiving agent accepts the handoff but lacks critical context to continue correctly. Guardrail: Add an eval step that checks whether the handoff package answers 'What was done?', 'What is blocked?', and 'What am I allowed to do?' before the receiving agent acts.

05

Operational Risk: Duplicate Work

What to watch: The receiving agent repeats steps the sender already completed because the handoff summary was ambiguous. Guardrail: Include explicit completed-step IDs and tool-call hashes in the handoff. The receiving agent must check these before executing any new action.

06

Operational Risk: Authority Drift

What to watch: The receiving agent escalates, writes, or deletes resources the sender was not authorized to touch. Guardrail: The handoff must include an explicit authority boundary block. The receiving agent's system prompt must enforce that boundary as a hard constraint.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready handoff instruction that packages agent state, unresolved dependencies, and authority boundaries for transfer to a specialized downstream agent.

The following prompt template is designed to be injected into your orchestrator agent's handoff instruction. It forces the originating agent to serialize its execution context into a structured package before transferring control. This prevents the common failure mode where a downstream agent receives only a vague task description and must re-discover context that was already established, leading to duplicated work, contradictory actions, and wasted tokens. Replace every square-bracket placeholder with live state from your agent runtime at the moment of handoff.

text
You are handing off execution to a specialized agent. Before transferring control, produce a complete handoff package using the structure below. Do not omit any section. If a section has no applicable content, explicitly state that it is empty and why.

## Handoff Package

### 1. Task State
- **Original Objective:** [ORIGINAL_OBJECTIVE]
- **Current Phase:** [CURRENT_PHASE]
- **Completed Steps (with evidence):**
  - [STEP_ID]: [OUTCOME] | Evidence: [EVIDENCE_REFERENCE]
- **In-Progress Step:** [STEP_ID] | Status: [STATUS] | Partial Output: [PARTIAL_OUTPUT]
- **Remaining Steps:** [REMAINING_STEP_LIST]

### 2. Relevant History
- **Key Decisions Made:**
  - [DECISION] | Rationale: [RATIONALE] | Made at step: [STEP_ID]
- **Errors Encountered and Resolutions:**
  - [ERROR] | Resolution: [RESOLUTION] | Step: [STEP_ID]
- **User Clarifications Received:**
  - [QUESTION] -> [ANSWER] | Step: [STEP_ID]

### 3. Unresolved Dependencies
- **Blocked Steps:** [STEP_ID] | Blocker: [BLOCKER_DESCRIPTION]
- **Pending Approvals:** [APPROVAL_ITEM] | Required from: [APPROVER_ROLE]
- **Missing Information:** [INFORMATION_GAP] | Needed for step: [STEP_ID]
- **Assumptions Awaiting Validation:** [ASSUMPTION] | Confidence: [LOW/MEDIUM/HIGH]

### 4. Authority Boundaries
- **Actions This Agent Is Authorized to Take:** [AUTHORIZED_ACTIONS]
- **Actions Requiring Escalation:** [ESCALATION_ACTIONS]
- **Hard Constraints:** [CONSTRAINTS]
- **Risk Level of Remaining Work:** [RISK_LEVEL]

### 5. Context References
- **Tool Outputs to Preserve:** [TOOL_OUTPUT_REFERENCES]
- **Source Documents:** [DOCUMENT_REFERENCES]
- **Checkpoint ID for Rollback:** [CHECKPOINT_ID]

### 6. Handoff Instructions
- **Why This Handoff Is Occurring:** [HANDOFF_REASON]
- **Expected Output from Downstream Agent:** [EXPECTED_OUTPUT_SCHEMA]
- **Return Handoff Required:** [YES/NO] | Condition: [RETURN_CONDITION]
- **Do Not Duplicate These Steps:** [COMPLETED_STEP_IDS]

Adapt this template by removing sections irrelevant to your agent architecture, but never remove the Unresolved Dependencies or Authority Boundaries sections—these are the most common sources of multi-agent failure. If your orchestrator uses structured tool calls rather than free-text handoffs, convert each section into a typed JSON schema with required fields and enum constraints. For high-risk domains, add a Human Review Required boolean field that gates the handoff until a human operator confirms the package is complete. Test the template by simulating a mid-execution handoff and verifying that the downstream agent can resume without asking any question already answered in the handoff package.

Before deploying this prompt into a production multi-agent system, build an eval that measures context sufficiency: give the handoff package to a fresh agent instance and measure whether it attempts to re-execute completed steps or re-request information already present. A passing eval requires zero duplicate work and zero redundant clarification requests. Also test the failure mode where the originating agent produces an incomplete handoff—your orchestrator should reject the handoff and request regeneration rather than forwarding a partial package to the downstream agent.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder must be populated from the agent runtime before invoking this prompt. Missing or stale values cause incomplete handoffs and downstream duplicate work.

PlaceholderPurposeExampleValidation Notes

[TASK_STATE]

Serialized representation of the originating agent's current task, including objective, status, and progress percentage.

{"objective": "Analyze Q3 sales data", "status": "in_progress", "progress_pct": 60, "current_step": "regional_breakdown"}

Must be valid JSON. Check for null or empty string. Reject if status is 'unknown' or progress_pct is outside 0-100.

[COMPLETED_STEPS]

Ordered list of steps already executed, including tool calls made, outputs received, and any side effects observed.

[{"step_id": 1, "action": "fetch_sales_db", "output_summary": "Retrieved 12,450 records", "status": "success"}]

Must be a non-empty array if TASK_STATE.progress_pct > 0. Each step must have a unique step_id. Validate output_summary is not null for completed steps.

[UNRESOLVED_DEPENDENCIES]

List of prerequisites or inputs the originating agent could not resolve, which the receiving agent must address before proceeding.

[{"dep_type": "data_missing", "description": "Q3 marketing spend by region", "blocked_steps": [4, 5]}]

Each dependency must reference at least one blocked_step. Validate dep_type is from allowed enum: data_missing, approval_required, tool_unavailable, clarification_needed.

[RELEVANT_HISTORY]

Condensed log of critical decisions, user clarifications, and context shifts that occurred during execution.

"User clarified on step 3 that EMEA region should exclude UK. Agent switched analysis model from linear to cohort-based after step 5 due to data skew."

Must be a string under 500 tokens. If null, flag as potential context loss. Check for contradiction with COMPLETED_STEPS outputs.

[AUTHORITY_BOUNDARIES]

Explicit list of actions the receiving agent is permitted or prohibited from taking, including spending limits, data scope, and escalation rules.

{"allowed": ["read_sales_db", "call_forecast_api"], "forbidden": ["write_to_crm", "send_email"], "spend_limit_usd": 0.50}

Must be a valid JSON object with 'allowed' and 'forbidden' arrays. If spend_limit_usd is present, validate it is a non-negative number. Reject handoff if forbidden includes all known tools.

[HANDOFF_REASON]

Categorization of why the handoff is occurring, used by the receiving agent to prioritize and contextualize its work.

"specialist_required: downstream task needs financial forecasting model; originating agent is a general data analyst."

Must be a non-empty string. Validate against expected reasons: specialist_required, token_limit_reached, policy_escalation, human_approval_gate, error_recovery. Flag if reason is 'unknown'.

[OUTPUT_SCHEMA_REQUIRED]

The exact JSON schema or format contract the receiving agent's final output must satisfy before the handoff is considered complete.

{"type": "object", "properties": {"forecast": {"type": "array"}, "confidence_interval": {"type": "number"}}, "required": ["forecast", "confidence_interval"]}

Must be valid JSON Schema. Validate required fields are present. Reject if schema is empty or missing 'type' field. Check for circular references.

[PRIOR_CONTEXT_ID]

A unique session or trace identifier linking this handoff to the parent workflow for logging, auditing, and state reconstruction.

"session_8a7b3f2c_run_4"

Must be a non-empty string matching the pattern of the system's trace ID. Validate it exists in the orchestration log. Reject if ID is stale (last activity > 24 hours ago unless explicitly allowed).

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Multi-Agent Handoff State Preservation Prompt into an agent orchestration layer with validation, retry, and logging.

The handoff prompt is not a standalone artifact; it is a contract between two agents inside an orchestration runtime. The orchestrator (or the handing-off agent itself) calls this prompt immediately before transferring control. The output is a structured handoff package that the receiving agent consumes as its initial context. To make this reliable in production, the harness must enforce schema compliance, validate context sufficiency, and provide a fallback path when the handoff package is incomplete or the receiving agent rejects it.

Start by wrapping the prompt call in a function that accepts the current agent's state, task history, and the target agent's capability description. The function should construct the prompt with the required placeholders: [CURRENT_AGENT_STATE], [TASK_HISTORY], [UNRESOLVED_DEPENDENCIES], [TARGET_AGENT_CAPABILITIES], and [AUTHORITY_BOUNDARIES]. After receiving the model response, validate the output against a strict JSON schema that includes required fields: task_state, relevant_history, unresolved_dependencies, authority_boundaries, and handoff_rationale. If validation fails, retry once with the validation errors injected into the prompt as [PREVIOUS_ERRORS]. If the second attempt fails, log the failure and escalate to a human operator or a fallback summarization agent.

For multi-agent systems using tool-calling models, the handoff package should be treated as a tool response that the receiving agent processes before its first action. Implement a receive_handoff tool that the receiving agent must call before any other tool. This tool parses the handoff JSON, loads it into the agent's working memory, and returns a confirmation that includes a checksum of the state. The orchestrator should compare this checksum against the original to detect silent corruption. Log every handoff event with a unique handoff_id, the sending agent, receiving agent, timestamp, schema validation result, and the receiving agent's confirmation checksum. This audit trail is essential for debugging duplicate work, dropped context, and authority boundary violations.

Model choice matters here. Use a model with strong instruction-following and structured output capabilities for the handoff prompt. If the handoff involves sensitive data or high-risk actions, route the prompt through a model with lower latency but higher reliability for schema adherence, and consider adding a lightweight validation model that checks the handoff package for completeness before the receiving agent consumes it. For long-running workflows, store the handoff package in a persistent state store keyed by handoff_id so the orchestrator can replay or audit the transition later.

Avoid wiring this prompt directly into the agent's main execution loop without the validation and retry wrapper. A malformed handoff package that reaches the receiving agent can cause cascading failures, repeated work, or silent context loss that is expensive to detect and repair. The harness should also enforce a timeout on the handoff prompt call itself—if the model takes too long to generate the package, fall back to a simpler state summary and flag the handoff for human review. The goal is to make handoffs boring, auditable, and recoverable, not to optimize for the happy path alone.

IMPLEMENTATION TABLE

Expected Output Contract

The JSON structure the handoff prompt must produce. Validate these fields before forwarding state to the receiving agent.

Field or ElementType or FormatRequiredValidation Rule

handoff_id

string (UUID v4)

Must match UUID v4 regex. Reject if missing or malformed.

timestamp

string (ISO 8601)

Must parse as valid ISO 8601 datetime. Reject if future-dated beyond 5-minute clock skew tolerance.

originating_agent

string

Must match registered agent ID from active agent registry. Reject if unknown agent.

receiving_agent

string

Must match registered agent ID and differ from originating_agent. Reject on self-handoff.

task_state

object

Must contain status (enum: in_progress, blocked, completed_with_errors), completed_steps (array of step IDs), and current_step (string or null). Reject if status is missing or invalid.

context_summary

string

Must be non-empty string between 50 and 2000 characters. Reject if empty or exceeds limit.

unresolved_dependencies

array of objects

Each object must have dependency_id (string), description (string), blocking_step (string), and priority (enum: critical, high, medium, low). Reject if critical dependency has no description.

authority_boundaries

object

Must contain allowed_actions (array of strings, min 1 item) and restricted_actions (array of strings). Reject if allowed_actions is empty or if any action appears in both arrays.

PRACTICAL GUARDRAILS

Common Failure Modes

Handoff state preservation breaks silently in production when context is incomplete, authority is ambiguous, or downstream agents misinterpret the package. These are the most common failure patterns and how to prevent them.

01

Silent Context Truncation

What to watch: The handoff prompt exceeds the receiving agent's context window, causing critical task state, unresolved dependencies, or authority boundaries to be silently dropped. The downstream agent proceeds with partial information and no warning. Guardrail: Implement a pre-handoff token budget check. If the handoff package exceeds 80% of the target model's context limit, trigger a compression step that preserves priority-ranked state and explicitly flags what was dropped.

02

Authority Boundary Drift

What to watch: The receiving agent misinterprets or expands its authority because the handoff package omitted explicit constraints on what it is allowed to do. This leads to over-execution, tool misuse, or actions outside the intended scope. Guardrail: Include a mandatory authority_boundary field in every handoff schema that enumerates permitted actions, forbidden actions, and escalation triggers. Validate this field is present and non-empty before the receiving agent begins execution.

03

Duplicate Work from Stale State

What to watch: The handoff package includes completed steps without clear completion markers, causing the receiving agent to re-execute work already done. This wastes tokens, produces conflicting outputs, and corrupts downstream state. Guardrail: Structure every handoff with an explicit completed_steps array containing step IDs, outputs, and verification status. Require the receiving agent to check this array before planning any new work and log any attempted re-execution as a warning.

04

Unresolved Dependency Propagation

What to watch: The sending agent passes a task with unresolved dependencies to the receiving agent without flagging them. The receiving agent either blocks indefinitely waiting for inputs that will never arrive or proceeds with missing data and produces incorrect results. Guardrail: Require a pending_dependencies block in the handoff schema that lists each unresolved dependency, its expected source, and a timeout or fallback action. The receiving agent must validate dependency resolution before executing dependent steps.

05

Tool Schema Incompatibility

What to watch: The sending agent references tools, function names, or parameter schemas that are not available to the receiving agent. The receiving agent either fails on the first tool call or hallucinates tool behavior. Guardrail: Include a tool_manifest in the handoff that maps tool references to actual available tools on the receiving side. Run a pre-execution compatibility check that verifies every referenced tool exists and has matching parameter schemas before the receiving agent begins work.

06

Intent Drift After Resume

What to watch: The receiving agent reinterprets the original goal through its own specialization lens, subtly shifting the objective without detecting the misalignment. The output is technically valid but solves the wrong problem. Guardrail: Embed the original goal statement and success criteria verbatim in the handoff package as an immutable original_intent field. Require the receiving agent to restate its understanding of the goal before execution and compare it against the original. Flag deviations above a similarity threshold for human review.

IMPLEMENTATION TABLE

Evaluation Rubric

Score handoff quality before forwarding to the receiving agent. Run these checks programmatically after JSON parsing.

CriterionPass StandardFailure SignalTest Method

Schema Compliance

Handoff JSON validates against the defined [OUTPUT_SCHEMA] with zero errors

JSON parse error or missing required fields in parsed output

Programmatic schema validation after JSON.parse()

Task State Completeness

All fields in [TASK_STATE] section are non-null and match expected types

Null or undefined values in required task state fields

Field-by-field null check against required field list

History Relevance

Included history entries reference only events within [CONTEXT_WINDOW] scope

History contains events outside the specified scope or duplicates

Timestamp and event ID range check against [CONTEXT_WINDOW] bounds

Dependency Resolution

All [UNRESOLVED_DEPENDENCIES] have non-empty descriptions and valid blocker IDs

Missing blocker ID or empty description in any dependency entry

String length check and ID format validation on dependency array

Authority Boundary Clarity

[AUTHORITY_BOUNDARIES] section contains explicit allowed and disallowed actions

Missing either allowed or disallowed list, or both lists are empty

Array presence and non-zero length check on both sub-fields

Duplicate Work Prevention

Handoff includes a unique [HANDOFF_ID] and references the prior handoff ID if resuming

Missing [HANDOFF_ID] or ID collision with a previously processed handoff

UUID format check and deduplication lookup against processed handoff log

Confidence Markers Present

Low-confidence items in state or history have explicit confidence scores below threshold

Low-confidence assertion without an accompanying confidence score

Scan state and history for uncertainty language, verify corresponding score field exists

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single orchestrator agent and a single specialist agent. Keep the handoff schema simple: task state, relevant history, unresolved dependencies, and authority boundaries. Skip formal eval and rely on manual spot checks of handoff packages.

Simplify the output schema to essential fields only:

code
[OUTPUT_SCHEMA]
{
  "task_id": "string",
  "current_state": "string",
  "relevant_history": ["string"],
  "unresolved_dependencies": ["string"],
  "authority_boundaries": "string"
}

Watch for

  • Missing unresolved dependencies that cause the specialist agent to stall
  • Overly broad authority boundaries that let the specialist agent exceed its scope
  • Handoff packages that omit critical context because the orchestrator assumed it was obvious
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.