This prompt template is for developers building conversational agents, copilots, or multi-turn API integrations where the model must produce a sequence of user and assistant turns with consistent role markers, optional tool calls, and state annotations. Use it when you need to generate synthetic conversation demonstrations for few-shot prompting, evaluation datasets, or to teach a model a specific multi-turn interaction pattern. This is not a prompt for running a live chat session. It is a meta-prompt that generates demonstration data you embed inside other prompts. It assumes you already have a target interaction pattern in mind and need the model to produce well-formatted examples that downstream systems can parse reliably.
Prompt
Multi-Turn Chat Demonstration Prompt Template

When to Use This Prompt
Defines the job-to-be-done, ideal user, required context, and limitations for the multi-turn chat demonstration prompt template.
The ideal user is an AI engineer or prompt architect who needs to programmatically generate training or evaluation data for a conversational system. You should have a clear specification of the desired turn structure, including how tool calls are interleaved, how state transitions are annotated, and what role markers your production parser expects. The prompt requires you to provide a target interaction pattern description, the number of turns, and any specific tool schemas or state variables that must appear. Without this context, the generated demonstrations will be generic and may not match your production format, leading to parser failures or model confusion when the examples are used in downstream prompts.
Do not use this prompt when you need a single-turn input-output pair, when you are generating data for a non-conversational task like classification or extraction, or when your production system uses a custom wire format that differs significantly from standard chat markup. This prompt is also inappropriate for generating live system responses—it produces static demonstration data, not runtime behavior. If your goal is to test a live agent's behavior, use an evaluation harness that sends real requests to the agent and captures its responses. If you need to teach refusal boundaries or safety policies through examples, pair this prompt with the Negative Example Formatting for Refusal Teaching prompt to ensure your demonstrations include appropriate boundary cases. After generating demonstrations, always validate them with a turn-boundary detection eval and a schema conformance check before embedding them in production prompts.
Use Case Fit
Where the Multi-Turn Chat Demonstration Prompt Template delivers value and where it introduces risk. Use these cards to decide if this pattern fits your current integration stage.
Good Fit: Agent Loop Development
Use when: you are building an agent that interleaves tool calls, observations, and final answers across multiple turns. Why: the template teaches the model the exact turn structure your application expects, reducing parsing errors in the agent harness.
Bad Fit: Single-Turn Classification
Avoid when: your task is a simple intent classification or entity extraction that completes in one response. Why: multi-turn demonstrations waste tokens and can confuse the model into waiting for a non-existent follow-up user message.
Required Input: Conversation Contract
Risk: without a defined schema for user/assistant/tool roles, the model invents its own delimiters. Guardrail: always provide a concrete turn schema (e.g., <|user|>, <|assistant|>, <|tool_call|>) in the system prompt before adding demonstrations.
Operational Risk: Context Contamination
Risk: the model leaks information from one demonstration turn into another, especially with long example sequences. Guardrail: use clear delimiter tokens between examples and run eval checks that verify turn boundary detection before production deployment.
Operational Risk: Tool Call Hallucination
Risk: the model copies tool names or argument structures from demonstrations rather than using the actual tool definitions provided at runtime. Guardrail: include negative examples showing incorrect tool calls and validate arguments against the live tool schema in your harness.
Good Fit: Stateful Conversation Systems
Use when: your application needs the model to track state transitions, remember user preferences, or resolve ambiguities across turns. Why: multi-turn demonstrations teach the model when to update state, ask clarifying questions, or reference prior context.
Copy-Ready Prompt Template
A copy-ready multi-turn chat demonstration template with role markers, tool calls, and state annotations for building conversational agents.
This template produces a multi-turn conversation demonstration that teaches the model consistent turn formatting, tool call interleaving, and state transition annotation. Use it when you need the model to internalize a specific interaction pattern—such as a support agent escalating to a human, a coding assistant calling a file-read tool, or a research agent updating its plan after new evidence arrives. The template enforces explicit role markers, optional tool call blocks, and optional state annotations so the model learns to separate user input, assistant reasoning, tool results, and state updates without ambiguity. Do not use this template when a single-turn instruction or a simple input-output pair would suffice; multi-turn demonstrations are expensive in tokens and should be reserved for patterns where turn ordering and state tracking are critical.
Below is the copy-ready template. Replace each square-bracket placeholder with concrete values for your use case. The [TOOL_CALL] and [STATE] lines are optional—remove them from any turn where they do not apply. Keep the delimiter conventions exactly as shown: --- separates turns, role markers are bolded, and tool calls use the TOOL >> prefix. Inconsistent delimiter formatting is the most common cause of schema drift and unexpected model behavior in multi-turn prompts.
text--- **User:** [USER_MESSAGE_1] --- **Assistant:** [ASSISTANT_RESPONSE_1] [TOOL_CALL] TOOL >> [TOOL_NAME]([TOOL_ARGUMENTS]) [/TOOL_CALL] [STATE] STATE >> [STATE_KEY]: [STATE_VALUE] [/STATE] --- **Tool:** [TOOL_OUTPUT_1] --- **Assistant:** [ASSISTANT_RESPONSE_2] [STATE] STATE >> [STATE_KEY]: [STATE_VALUE] [/STATE] --- **User:** [USER_MESSAGE_2] --- **Assistant:** [ASSISTANT_RESPONSE_3]
To adapt this template for your application, start by defining the exact role markers your system uses. If your chat API uses user, assistant, and tool roles, map those directly. If you have additional roles such as system or function, add them with the same formatting pattern. For tool calls, replace [TOOL_NAME] with the actual function name and [TOOL_ARGUMENTS] with a JSON string or key-value representation that matches your function-calling schema. The [STATE] block is optional but valuable for teaching the model to track session-level variables such as escalation_required: true, plan_step: 3, or user_authenticated: false. Before shipping, validate that your delimiter sequence does not appear in user or tool content—if it can, switch to a less common delimiter or add escaping logic. For high-risk workflows such as healthcare or finance, add a human-review step that checks whether state transitions in the demonstration match your business rules before the prompt enters production.
Prompt Variables
Placeholders required by the Multi-Turn Chat Demonstration Prompt Template. Replace each with concrete values before sending the prompt to the model. Validation notes describe how to check that the placeholder is correctly populated.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CONVERSATION_GOAL] | Describes the task the multi-turn demonstration is teaching the model to perform | Book a flight, handle objections, and confirm payment details over 5 turns | Check that the goal is a single sentence describing the end-to-end task, not a list of instructions |
[TURN_COUNT] | Specifies the exact number of user-assistant turns in the demonstration | 5 | Must be an integer between 2 and 20; parse check for non-integer or out-of-range values |
[ROLE_MARKERS] | Defines the syntax used to label each turn's speaker in the demonstration | User: / Assistant: | Must contain exactly two distinct markers; regex check for balanced delimiter usage across all turns |
[TOOL_CALL_SYNTAX] | Specifies the format for interleaved tool calls within assistant turns when tool use is part of the demonstration | <tool_call>{"name": "search_flights", "arguments": {"origin": "SFO"}}</tool_call> | If tool calls are present, validate that each tool call block is parseable JSON with required 'name' and 'arguments' fields; null allowed if demonstration has no tool calls |
[STATE_ANNOTATION_SYNTAX] | Defines how state transitions are annotated between turns, such as slot-filling progress or belief state updates | [STATE: origin=SFO, destination=JFK, date=confirmed] | If state annotations are present, validate that each annotation contains at least one key=value pair; null allowed if no state tracking is needed |
[TURN_SEPARATOR] | Specifies the delimiter placed between consecutive turns to prevent boundary ambiguity | Must be a non-empty string that does not appear in any turn content; substring check against all turn bodies | |
[EXAMPLE_DOMAIN] | Sets the domain context for the demonstration to ensure realistic entity values and terminology | Travel booking | Must be a short domain label; verify that turn content uses domain-appropriate entities and avoids cross-domain leakage |
[OUTPUT_SCHEMA] | Describes the expected structure of the final assistant response after the demonstration concludes | {"booking_id": "string", "status": "confirmed|cancelled", "total_price": "number"} | Validate that the schema is valid JSON Schema or a parseable type description; schema conformance check on final output |
Implementation Harness Notes
How to wire the multi-turn chat demonstration prompt into a reliable application workflow.
The multi-turn chat demonstration prompt is not a standalone chat endpoint—it is a prompt generator that produces formatted example sequences for use inside other system prompts. The implementation harness must treat this prompt as a pre-processing step that runs before the main conversational agent receives its final instructions. The typical integration pattern is: (1) collect the target behavior description, tool definitions, and output schema; (2) call this prompt to generate a multi-turn demonstration block; (3) inject the generated demonstration into the system prompt of the downstream conversational agent; (4) validate that the assembled prompt parses correctly before deployment.
Validation and assembly checks are the most important part of the harness. Before injecting generated demonstrations into a production system prompt, run automated checks for: turn boundary detection (every user turn must have a corresponding assistant or tool response), role marker consistency (no mixed or malformed role prefixes), tool call argument schema conformance (validate against the provided tool definitions), and context contamination (ensure entities or facts from one example turn do not leak into unrelated turns). A lightweight validation script should parse the generated demonstration block, extract each turn, and assert these properties. If validation fails, retry the generation call with a more explicit error message appended to the input, or fall back to a manually curated demonstration set.
Model choice and latency considerations matter here. This prompt is typically run once per system prompt update—not per user request—so latency tolerance is higher. Use a capable model (GPT-4o, Claude 3.5 Sonnet, or equivalent) for generation quality. Cache the generated demonstration block and version it alongside the system prompt. When tool definitions or behavior requirements change, regenerate and re-validate. For high-risk conversational agents (healthcare, finance, legal), add a human review gate before the generated demonstrations are deployed: a domain expert should verify that the example turns do not teach unsafe patterns, over-refusal, or incorrect escalation behavior. Log every generated demonstration version with its validation results and reviewer sign-off for audit trails.
Integration with RAG and tool-calling agents requires extra care. If the downstream agent uses retrieval or function calling, the generated demonstrations must include realistic tool call interleaving and source citation patterns. The harness should accept a [TOOLS] placeholder containing the actual function schemas and a [CONTEXT] placeholder with sample retrieved passages. After generation, validate that every simulated tool call in the demonstration matches an actual function signature and that citation markers reference the provided context passages. When the agent's tool set changes, regenerate the demonstrations immediately—stale tool call examples are a leading cause of production agent failures.
Expected Output Contract
Fields, format, and validation rules for the multi-turn demonstration generated by the prompt. Use this contract to build a parser and validator before wiring the prompt into an application.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
[DEMONSTRATION_BLOCK] | Array of turn objects | Must parse as valid JSON array. Length must be >= 2 and <= [MAX_TURNS]. Each element must match the turn object schema. | |
turn.role | String enum: user, assistant, tool, system | Must be one of the allowed enum values. Case-sensitive. No unknown roles permitted. First turn must be user. | |
turn.content | String or null | Must be a non-empty string for user and assistant roles. Must be null for tool roles. String length must not exceed [MAX_CONTENT_LENGTH]. | |
turn.tool_calls | Array of tool call objects or null | If present, must be a valid array. Each element must contain id (string), name (string matching [TOOL_LIST]), and arguments (valid JSON string). Only permitted when role is assistant. | |
turn.tool_call_id | String or null | Required when role is tool. Must match the id of a preceding assistant turn's tool_calls entry. Must be null for user and assistant roles. | |
turn.state_annotation | String or null | If present, must be a non-empty string describing state change. Use only for turns that alter conversation state (e.g., order_created, escalation_triggered). Must not leak information unavailable at that turn. | |
turn.timestamp_offset | String (ISO 8601 duration) or null | If present, must be a valid ISO 8601 duration string (e.g., PT30S). Represents simulated time elapsed since previous turn. Must be null for the first turn. |
Common Failure Modes
Multi-turn demonstrations break in predictable ways. Here are the most common failure modes and how to guard against them before they reach production.
Turn Boundary Leakage
What to watch: The model merges adjacent demonstration turns, treating a user message and the following assistant response as a single block. This corrupts role assignment and causes the model to generate both sides of the conversation. Guardrail: Use unambiguous delimiter tokens between turns and validate with a boundary detection eval that confirms the model can identify where each turn starts and ends.
Context Contamination Across Examples
What to watch: Information from one demonstration turn bleeds into the model's response to a later turn, especially when examples share similar topics or entity names. The model treats the demonstration as a continuous narrative rather than independent examples. Guardrail: Insert explicit example separators and test with overlapping entity names across demonstrations to measure contamination rates.
Tool Call Interleaving Collapse
What to watch: When demonstrations include tool calls between user and assistant turns, the model flattens the sequence—either skipping the tool call entirely or merging the tool response into the assistant message. Guardrail: Use distinct formatting for tool call boundaries and include negative examples showing incorrect flattening. Validate with an eval that checks tool call presence and argument preservation.
State Annotation Drift
What to watch: State transition annotations embedded in demonstrations (such as [STATE: collecting_address]) are either ignored by the model or hallucinated in production turns where no state change occurred. Guardrail: Keep state annotations outside the model's generation path—store them in application logic—and only include them in demonstrations when they are essential for teaching turn-taking behavior.
Role Marker Confusion Under Adversarial Inputs
What to watch: User inputs in production that contain strings resembling role markers (such as assistant: or system:) cause the model to misinterpret who is speaking, especially when demonstrations use plain-text role prefixes. Guardrail: Use structured role encoding (API-level message objects rather than text markers) and test with adversarial inputs containing role-like strings in your eval suite.
Demonstration Length Overfitting
What to watch: The model learns the exact turn count from demonstrations and struggles when production conversations are shorter or longer. It either truncates prematurely or pads with hallucinated turns to match the demonstration length. Guardrail: Include demonstrations of varying lengths in your example set and test with conversations that are 1-turn, 3-turn, and 10-turn to verify length generalization.
Evaluation Rubric
Use this rubric to test multi-turn chat demonstration outputs before shipping. Each criterion targets a specific failure mode observed in production conversational agents.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Turn Boundary Detection | All user/assistant role markers are correctly parsed with no merged or split turns | Adjacent user messages appear as one turn; assistant response spans multiple turn blocks | Parse output with delimiter regex; assert turn count matches expected count from input |
Role Marker Integrity | Every message block has exactly one role marker matching the input sequence | Role marker missing, duplicated, or swapped (assistant labeled as user) | Extract all role markers in order; compare array equality with ground-truth role sequence |
Tool Call Interleaving | Tool call and tool response blocks appear in correct sequence between user and assistant turns | Tool call appears after assistant response; tool response missing or out of order | Validate tool call indices increment monotonically; assert tool response follows each call within same turn |
State Transition Annotation | State changes are annotated with before/after values and transition trigger | State annotation references a turn that does not exist; before value does not match prior state | Parse state annotations; assert referenced turn IDs exist; compare before value with prior turn's after value |
Context Contamination | No information from one demonstration example leaks into another example's turns | Entity or value from Example A appears in Example B's assistant response without grounding | Extract named entities per example block; assert zero overlap between disjoint example sets |
Output Schema Conformance | Output matches the specified schema with all required fields present and correctly typed | Missing required field; field type mismatch; extra fields not in schema | Validate output against JSON Schema; assert all required fields present; assert no additional properties if schema forbids |
Multi-Turn Coherence | Assistant responses in later turns reference prior turns accurately without hallucinated context | Assistant references a decision or value never stated; contradicts prior turn's output | Extract claims from each assistant turn; assert each claim is supported by prior turns or tool responses |
Truncation Handling | Incomplete final turn is flagged rather than silently completed with hallucinated content | Final turn appears complete but contains fabricated closing statements not in model output | Simulate mid-turn truncation; assert output includes truncation marker or abstains rather than inventing closure |
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
Start with the base multi-turn template and 3-5 example conversations. Use simple role markers (user:, assistant:) instead of full API format. Skip tool call interleaving and state annotations until the turn structure is stable.
codeuser: [FIRST_USER_MESSAGE] assistant: [EXPECTED_RESPONSE] user: [FOLLOW_UP_MESSAGE] assistant: [EXPECTED_FOLLOW_UP]
Watch for
- Turn boundary ambiguity when messages contain colons or newlines
- Model confusing example turns with real conversation turns
- Missing context carryover between turns in longer demonstrations

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