Inferensys

Prompt

Session Handoff Prompt Between Agents

A practical prompt playbook for generating structured handoff summaries when transferring conversations between specialized agents 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 specific job, the target user, and the operational constraints for the session handoff prompt.

This prompt is designed for multi-agent systems where a conversation must be transferred from one specialized assistant to another. The core job-to-be-done is generating a structured, lossless handoff summary that allows the receiving agent to continue the workflow without repeating steps, asking already-answered questions, or losing critical user preferences. The ideal user is an AI/ML engineer or platform developer building an agent orchestration layer, where a router or supervisor agent delegates tasks to sub-agents with distinct capabilities or domain knowledge.

Use this prompt when the handoff is between agents with different system instructions, tool access, or knowledge bases. The required context includes the full conversation transcript, the sending agent's role and completed actions, and any unresolved tasks or user constraints. Do not use this prompt for simple, single-agent context summarization or for logging purposes. It is specifically for active state transfer where the receiving agent will immediately act on the information. The prompt is overkill if the receiving agent is stateless or if the conversation is simply ending.

Before implementing, ensure you have a clear contract for the handoff schema. The output must be machine-readable to be injected into the receiving agent's context. The primary failure mode is information loss, where a pending action or user preference is omitted from the summary, causing the receiving agent to make a contradictory or redundant request. A secondary risk is carrying over stale context that the user has since corrected. Always pair this prompt with a validation step that checks the handoff summary against the last few turns of the conversation to confirm that active intent and recent corrections are accurately captured.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Session Handoff Prompt works, where it fails, and the operational preconditions required before deploying it in a multi-agent system.

01

Good Fit: Specialized Agent Pipelines

Use when: a conversation must transfer from a general triage agent to a domain-specialist agent (e.g., billing, technical support). Guardrail: define a strict handoff schema so the receiving agent never needs to re-ask questions already answered.

02

Bad Fit: Single-Agent Chatbots

Avoid when: only one agent handles the entire conversation. Risk: the handoff prompt adds latency and token cost with no routing benefit. Guardrail: use a simple session summary prompt instead of a full handoff structure.

03

Required Input: Structured Conversation State

Risk: the handoff prompt produces vague or incomplete summaries if the upstream agent does not track slots, intents, and pending actions explicitly. Guardrail: require a structured dialogue state object as input; do not rely on raw transcript alone.

04

Required Input: Agent Capability Description

Risk: the handoff summary includes actions the receiving agent cannot perform, causing immediate failure. Guardrail: provide a machine-readable capability statement for the target agent so the handoff prompt can filter or flag unsupported handoff items.

05

Operational Risk: Information Loss at Boundary

Risk: critical context such as user tone, unresolved objections, or partial completions is dropped during compression. Guardrail: implement an eval that compares pre-handoff state to post-handoff state and flags missing required fields before the receiving agent acts.

06

Operational Risk: Contradictory State Transfer

Risk: the handoff summary contradicts the raw conversation history, causing the receiving agent to confidently execute the wrong action. Guardrail: run a contradiction detection eval between the handoff payload and the last N turns of the transcript before ingestion.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for generating structured handoff summaries when transferring a conversation between specialized agents.

This template is the core instruction set for a handoff agent. Its job is to read the raw conversation history and produce a structured, lossless summary that the receiving agent can use to continue the work without repeating steps, asking answered questions, or violating established user preferences. The template uses square-bracket placeholders so you can wire it into your existing multi-agent orchestration code. Every placeholder represents a variable your application must supply at runtime.

code
SYSTEM:
You are a Session Handoff Agent. Your only job is to produce a structured handoff summary from the provided conversation history. Do not continue the conversation. Do not greet the user. Do not take any action on behalf of the user.

INPUT:
[CONVERSATION_HISTORY]

INSTRUCTIONS:
1. Analyze the entire conversation history to extract the following structured information.
2. If a field has no applicable information, use `null` or an empty array `[]` as specified.
3. Do not infer, assume, or hallucinate information not present in the history.
4. Preserve the user's exact terminology for preferences and constraints.

OUTPUT_SCHEMA:
{
  "handoff_summary": {
    "primary_intent": "string (the user's main goal, stated as a concise imperative)",
    "completed_steps": [
      {
        "step": "string (what was done)",
        "result": "string (outcome or confirmation)",
        "timestamp": "string (ISO 8601 if available, else relative turn reference)"
      }
    ],
    "pending_actions": [
      {
        "action": "string (what needs to be done next)",
        "owner": "string (user | agent | system)",
        "blockers": ["string (what is preventing this action)"],
        "priority": "string (high | medium | low)"
      }
    ],
    "unresolved_questions": [
      {
        "question": "string (the open question)",
        "asked_by": "string (user | agent)",
        "context": "string (why this question matters)"
      }
    ],
    "user_preferences": {
      "explicit": ["string (stated preference)"],
      "observed": ["string (behavioral pattern, noted as observation)"]
    },
    "active_constraints": ["string (rules, deadlines, or limits in effect)"],
    "key_entities": [
      {
        "name": "string",
        "type": "string (person | product | company | policy | other)",
        "role": "string (how this entity relates to the conversation)"
      }
    ],
    "conversation_tone": "string (e.g., urgent, exploratory, frustrated, neutral)",
    "risk_flags": ["string (escalation signals, compliance concerns, user dissatisfaction indicators)"],
    "handoff_context": "string (a 2-3 sentence narrative summary for the receiving agent to read first)"
  }
}

CONSTRAINTS:
[CONSTRAINTS]

EXAMPLES:
[EXAMPLES]

To adapt this template, start by defining your [CONSTRAINTS]. This is where you enforce domain-specific rules, such as PII redaction requirements, maximum summary length, or mandatory fields for regulated workflows. Next, supply 2-3 [EXAMPLES] that demonstrate the desired output for typical handoff scenarios in your product. These few-shot examples are critical for teaching the model the expected level of detail and the boundary between factual extraction and inference. Finally, replace [CONVERSATION_HISTORY] with your application's serialized dialogue, ensuring that speaker roles and turn boundaries are clearly delimited. The output schema is designed to be parsed directly by your orchestrator, so validate the JSON structure before forwarding it to the next agent. For high-risk domains, add a human review step that checks the risk_flags array and the handoff_context narrative before the receiving agent acts.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the session handoff prompt. Each placeholder must be populated by the originating agent or the orchestration layer before the handoff summary is generated. Missing or malformed variables cause information loss in the receiving agent.

PlaceholderPurposeExampleValidation Notes

[CONVERSATION_HISTORY]

Full transcript or structured turn log from the originating agent's session with the user

User: I need to reset my MFA. Agent: I can help with that. Can you confirm your identity first? User: Yes, my employee ID is 84721.

Must be non-empty string. Truncate to last N turns if context budget is constrained. Validate that turn boundaries are explicit and speaker roles are labeled.

[ACTIVE_INTENT]

Primary user goal or request that is currently in progress and not yet fulfilled

Account recovery with MFA reset for employee ID 84721

Must be a single concise sentence. Null allowed if no active intent exists. Validate that intent is actionable and not a vague category like 'support'.

[COMPLETED_STEPS]

Ordered list of actions the originating agent has already performed successfully

  1. Verified employee ID 84721 exists in directory. 2. Confirmed user has access to recovery email on file. 3. Initiated identity verification challenge.

Must be a JSON array of strings or null. Each step must describe a completed action, not an intent. Validate no duplicate steps and no future-tense language.

[PENDING_ACTIONS]

Ordered list of actions the receiving agent must complete to fulfill the active intent

  1. Validate identity verification response. 2. Issue temporary MFA bypass. 3. Guide user through MFA re-enrollment.

Must be a JSON array of strings or null. Each action must be specific and executable by the receiving agent. Validate no actions already listed in COMPLETED_STEPS.

[USER_PREFERENCES]

Explicit user constraints, preferences, or requirements stated during the session

User prefers SMS for verification codes, not email. User requested no jargon in explanations.

Must be a JSON array of strings or null. Only include preferences explicitly stated by the user, not inferred defaults. Validate each preference is attributable to a specific user turn.

[UNRESOLVED_CONTEXT]

Open questions, ambiguities, or missing information the receiving agent must clarify

User's recovery email on file may be outdated. Identity verification response not yet received.

Must be a JSON array of strings or null. Each item must describe a gap that blocks progress, not a general note. Validate that unresolved items are not already addressed in COMPLETED_STEPS.

[SESSION_METADATA]

Structured metadata about the originating session for audit and continuity

{"session_id": "sess_9a2b", "agent_role": "identity_verification", "started_at": "2025-03-15T14:22:00Z", "turns_completed": 7, "escalation_reason": "specialized_mfa_handoff"}

Must be valid JSON object. Required fields: session_id, agent_role, started_at. Validate timestamp is ISO 8601 and session_id is non-empty. Null not allowed.

[CONSTRAINTS]

Policy, compliance, or operational constraints the receiving agent must respect

Do not disclose account recovery methods beyond MFA reset. Compliance boundary: PII must not be logged in handoff audit trail.

Must be a JSON array of strings. Each constraint must be a prohibitive or restrictive rule. Validate no constraints conflict with PENDING_ACTIONS. Null allowed if no special constraints apply.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Session Handoff Prompt into a multi-agent application with validation, retries, and audit logging.

Integrating the session handoff prompt into a production multi-agent system requires treating the handoff summary as a critical data contract, not just a text blob. The prompt should be called by the current agent when a handoff trigger is detected—typically a classifier router, an explicit user request, or a task-completion signal. The output must be a structured JSON object that the target agent can parse programmatically. Before passing the summary to the next agent, validate it against a strict schema: check that required fields like active_intent, completed_steps, pending_actions, and unresolved_context are present and non-empty where expected. If validation fails, re-prompt the model with the specific schema errors rather than silently passing incomplete state to the downstream agent.

Implement a retry loop with a maximum of two attempts for schema validation failures. On the first failure, append the validation error message to the prompt and re-request the structured output. If the second attempt also fails, log the raw output and the errors, then fall back to a degraded handoff: pass whatever valid fields exist and flag the handoff as partial_handoff: true with a validation_errors field. The receiving agent should check for this flag and, when present, ask the user a brief clarifying question before proceeding with any irreversible actions. For model choice, prefer a model with strong instruction-following and structured output capabilities (e.g., GPT-4o, Claude 3.5 Sonnet) since schema adherence is the primary failure mode. Avoid smaller or older models that tend to drop fields or hallucinate values under complex output constraints.

Log every handoff event—successful, partial, or failed—to your observability platform. The log should include the session_id, source_agent_id, target_agent_id, the validated handoff payload, the handoff_timestamp, and the validation_status. This audit trail is essential for debugging multi-agent workflows where context loss or contradictory state can cascade across agents. Additionally, implement a handoff relevance check in the receiving agent: before acting on the summary, have the target agent evaluate whether the handoff context is still relevant or has been superseded by a new user message that arrived during the handoff window. This prevents stale-state execution, which is a common failure mode in asynchronous agent architectures. Finally, for high-stakes domains like healthcare or finance, require a human-in-the-loop review step before the receiving agent executes any action that modifies external systems based solely on handoff context.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the structured handoff summary generated by the Session Handoff Prompt Between Agents. Use this contract to parse and validate the model's output before passing it to the receiving agent.

Field or ElementType or FormatRequiredValidation Rule

handoff_summary.active_intent

string

Must be a non-empty string summarizing the user's primary goal. Length must be between 10 and 500 characters.

handoff_summary.completed_steps

array of strings

Each element must be a non-empty string. The array must not contain duplicate strings. Maximum 20 items.

handoff_summary.pending_actions

array of objects

Each object must contain a non-empty 'action' string and a 'priority' string from the set ['high', 'medium', 'low']. Maximum 10 items.

handoff_summary.user_preferences

object

If present, must be a valid JSON object. Keys must be non-empty strings. Values must be strings, numbers, or booleans. Null values are not allowed.

handoff_summary.unresolved_context

array of objects

Each object must contain a non-empty 'question' string and a nullable 'last_relevant_turn' integer. Maximum 5 items.

handoff_summary.session_metadata

object

Must contain a 'session_id' string, a 'handoff_timestamp' string in ISO 8601 format, and a 'source_agent' string. No additional properties are allowed.

handoff_summary.escalation_required

boolean

Must be a strict boolean value (true or false). If true, the 'escalation_reason' field must be a non-empty string.

handoff_summary.escalation_reason

string or null

Required and must be a non-empty string if 'escalation_required' is true. Must be null if 'escalation_required' is false.

PRACTICAL GUARDRAILS

Common Failure Modes

Handoff prompts between agents are brittle. Information loss, contradictory state, and irrelevant context transfer are the most common production failures. Each card below identifies a specific failure mode and a concrete guardrail to prevent it.

01

Silent Intent Drop

What to watch: The primary user goal or active intent is omitted from the handoff summary, causing the receiving agent to start a new task or ask the user to repeat themselves. This often happens when the handoff prompt over-indexes on recent turns and forgets the original objective. Guardrail: Require the handoff prompt to explicitly restate the active_intent from the session state as the first field in the output schema, validated against the original session start marker.

02

Pending Action Starvation

What to watch: Actions the first agent committed to but did not complete (e.g., 'I will send that email') are missing from the handoff. The receiving agent has no awareness of the commitment, breaking user trust. Guardrail: Maintain a dedicated pending_actions list in session state. The handoff prompt must include a PENDING_COMMITMENTS section that is populated from this list, with a post-handoff validation check that the list is non-empty if the pre-handoff state had open items.

03

Contradictory State Transfer

What to watch: The handoff summary contains facts that conflict with the detailed turn history (e.g., summary says 'user prefers email' but turn 4 shows they asked for a phone call). The receiving agent acts on the wrong preference. Guardrail: Add a state_contradiction_check step before finalizing the handoff. Use a secondary prompt to compare the generated summary against the last N turns of raw dialogue, flagging any inversions of user-stated facts or preferences.

04

Irrelevant Context Flooding

What to watch: The handoff prompt dumps the entire conversation history into the new agent's context, including resolved issues, small talk, and dead ends. This wastes the context window, increases latency, and distracts the receiving agent from the active task. Guardrail: The handoff prompt must classify each turn as active, resolved, or stale before generation. Only active and explicitly tagged critical-resolved items should be included in the final payload.

05

Tool Call Orphaning

What to watch: The first agent made a tool call (e.g., create_draft) and received a result, but the handoff summary only describes the user's text and omits the tool result. The receiving agent lacks the data it needs and may re-execute the tool, creating duplicates. Guardrail: The handoff prompt must include a TOOL_OUTPUTS section that captures the function name, arguments, and structured result of any tool call whose output is still relevant to the active workflow.

06

Escalation Reason Erosion

What to watch: The specific reason for handoff (e.g., 'transfer to billing specialist due to refund policy complexity') is generalized to 'transfer to support'. The receiving agent lacks the context to pick up the task efficiently and re-asks diagnostic questions. Guardrail: The handoff prompt must include a mandatory handoff_reason field with a structured sub-field for specific_trigger (the exact user statement or system event that caused the transfer) and required_capability (the skill the receiving agent must have).

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the quality of a session handoff summary before shipping. Use these checks to catch information loss, contradictory state, and irrelevant context transfer.

CriterionPass StandardFailure SignalTest Method

Active Intent Preservation

The primary user goal and current workflow step are explicitly stated in the handoff summary

Handoff summary omits the user's stated goal or describes a completed step as still in-progress

Diff the original conversation's last-turn intent against the handoff summary's [ACTIVE_INTENT] field; require exact match on goal label

Completed Step Accuracy

All steps marked complete in the handoff match steps the assistant explicitly confirmed as done in the conversation

A step is marked complete in the handoff but the conversation shows it was only proposed or partially executed

Parse [COMPLETED_STEPS] array and cross-reference each entry against conversation turn markers; flag any step without an explicit confirmation turn

Pending Action Completeness

Every unresolved question, deferred task, or required follow-up from the conversation appears in the handoff's pending actions list

A user question left unanswered or a promised follow-up is absent from [PENDING_ACTIONS]

Extract all question marks and commitment phrases from the last 5 turns; verify each has a corresponding entry in [PENDING_ACTIONS] or a null reason

User Preference Carry-Forward

Explicit user preferences and constraints stated during the session are present in the handoff's preference block

A user constraint like 'keep responses under 3 sentences' or 'use UTC timezone' is dropped from [USER_PREFERENCES]

Maintain a running preference register during the conversation; assert that every registered preference appears in the handoff's preference object

Contradiction-Free State

No field in the handoff summary contradicts any other field or the source conversation

The handoff marks a task as both complete and pending, or states a preference that conflicts with an earlier user correction

Run a contradiction detection prompt over the handoff JSON; flag any field pair with opposing boolean states or mutually exclusive values

Handoff Relevance

The receiving agent role is identified and the summary includes only context relevant to that agent's domain

The handoff includes verbose dialogue history or domain-irrelevant details that waste the receiving agent's context budget

Classify each field in the handoff against the receiving agent's role description; flag fields with zero semantic overlap to the target domain

Schema Compliance

The handoff output strictly matches the defined JSON schema with all required fields present and correctly typed

Missing required fields, incorrect types, or extra fields that violate the output contract

Validate the handoff JSON against the [OUTPUT_SCHEMA] using a schema validator; reject on any violation

Source Grounding

Every factual claim in the handoff can be traced to a specific turn or tool output in the source conversation

The handoff contains a claim, value, or status that has no corresponding evidence in the conversation history

For each non-null field in the handoff, require a citation to a turn index or tool call ID; flag any field without a valid source reference

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt template with minimal validation. Focus on getting the handoff structure right before adding schema enforcement. Run a few handoff scenarios manually and inspect the JSON output for completeness.

  • Remove strict [OUTPUT_SCHEMA] enforcement; accept markdown or free-text handoff summaries.
  • Replace structured [CONSTRAINTS] with a single sentence: "Include active intent, completed steps, pending actions, and unresolved context."
  • Skip eval assertions; rely on spot-checking 5-10 handoff examples.

Watch for

  • Missing fields when the model skips sections like unresolved_context or user_preferences.
  • Overly verbose summaries that waste context budget in the receiving agent.
  • Hallucinated completion status for steps the agent never actually performed.
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.