Use this prompt when you need a machine-readable, turn-by-turn audit trail of state mutations inside a compliance-sensitive chat system. The primary job-to-be-done is generating a structured JSON record that answers three questions after every user or assistant turn: what state field changed, why it changed, and what evidence justified the change. This is essential for support operations teams in regulated industries (finance, healthcare, insurance) where auditors require proof that the assistant did not silently drop a customer commitment, alter a policy interpretation, or overwrite a verified fact without a traceable reason. The ideal user is an AI engineer or compliance architect integrating this prompt into a stateful chat pipeline that already maintains a prior state object, a conversation history, and a set of system policies.
Prompt
Turn-Level State Change Audit Record Prompt

When to Use This Prompt
Identifies the ideal operational context, required inputs, and explicit limitations for the Turn-Level State Change Audit Record Prompt.
This prompt is not a replacement for full session snapshots or human-readable decision narratives. It produces a focused, machine-ingestible change record—not a complete state dump. You must pair it with the Session State Snapshot Generation Prompt for full serialization and the Conversation Decision Trace Prompt for human review. Do not use this prompt when you lack a structured prior state object to diff against; it will hallucinate changes if forced to infer state from raw text alone. The prompt assumes you have access to the current turn, the prior state object, and any relevant policy documents. It works best when state fields are typed (e.g., customer_intent, verified_identity, payment_method) and when policies are explicit enough to cite by ID or rule reference.
Before deploying this prompt, define the state schema you will audit. The prompt's output includes changed_fields, unchanged_fields, and justification blocks, each referencing field names and evidence sources. If your state object is a flat dictionary of 50 keys, the audit record will be noisy and expensive. Instead, scope the audit to high-risk fields: those that affect downstream actions, compliance obligations, or user-facing commitments. For each field, decide whether a change requires a policy citation, a user utterance quote, or a tool-return reference. This constraint prevents the model from generating vague justifications like 'updated based on conversation context.' The next step after reading this section is to review the prompt template and adapt the [STATE_SCHEMA] and [POLICY_DOCUMENTS] placeholders to your system's actual schema and rules. Avoid using this prompt on every turn for low-risk fields; reserve it for state mutations that matter to auditors.
Use Case Fit
Where the Turn-Level State Change Audit Record Prompt delivers value and where it introduces risk or unnecessary complexity.
Good Fit: Compliance-Mandated Audit Trails
Use when: regulatory requirements or internal policy demand a timestamped, evidence-backed record of every state mutation. Guardrail: map each output field to a specific compliance control ID so auditors can trace coverage.
Good Fit: Multi-Turn Debugging in Production
Use when: support escalations require reconstructing exactly what the assistant believed and why at each turn. Guardrail: store audit records alongside conversation logs with a shared session_id and turn_index for fast retrieval.
Bad Fit: Real-Time, Sub-100ms Latency Budgets
Avoid when: the prompt adds unacceptable latency to synchronous user-facing turns. Guardrail: run audit generation asynchronously after the user-facing response is sent, or sample a percentage of traffic instead of auditing every turn.
Bad Fit: Stateless Single-Turn Workflows
Avoid when: the assistant resets state after each request and carries no session context. Guardrail: use a lightweight request log instead; the full state-change audit record adds schema overhead with no state to track.
Required Inputs
Must provide: the prior state object, the current user or assistant turn, any retrieved evidence, and the active policy or instruction set. Guardrail: validate that all four inputs are non-null before invoking the prompt; return a structured MISSING_INPUT error otherwise.
Operational Risk: Audit Record Drift
Risk: the model changes how it structures justifications over time, breaking downstream parsers. Guardrail: pin the output schema with strict field definitions and run a schema conformance eval on every generated record before storage.
Copy-Ready Prompt Template
A reusable prompt that produces a structured JSON audit record of what state changed, why, and on what evidence after each user or assistant turn.
This prompt template generates a turn-level state change audit record for compliance and support operations teams building auditable chat systems. It is designed to be called after every user or assistant turn in a conversation, producing a machine-readable JSON object that captures what changed in the conversation state, the evidence that justified the change, and a timestamp-ordered trace suitable for downstream review or storage. The prompt assumes you have access to the current turn's input, the prior conversation state, and any relevant system policies or retrieved evidence. Replace each square-bracket placeholder with your application's actual data before sending the prompt to the model.
textYou are an audit record generator for a regulated conversation system. Your task is to produce a structured JSON record that documents every state change that occurred during the most recent conversation turn. You must cite specific evidence for each change and maintain strict timestamp ordering. ## INPUT - Current turn speaker: [SPEAKER_ROLE] - Current turn content: [TURN_CONTENT] - Prior conversation state (JSON): [PRIOR_STATE] - Active system policies (JSON): [ACTIVE_POLICIES] - Retrieved evidence used this turn (JSON array, may be empty): [RETRIEVED_EVIDENCE] - Conversation metadata: [CONVERSATION_METADATA] ## OUTPUT SCHEMA Return ONLY a valid JSON object with this exact structure: { "audit_record": { "record_id": "string, unique identifier for this audit record", "conversation_id": "string, from conversation metadata", "turn_number": "integer, from conversation metadata", "speaker": "string, user or assistant", "timestamp": "string, ISO 8601 UTC", "state_changes": [ { "change_id": "string, unique within this record", "state_path": "string, dot-notation path to the changed field in prior state", "change_type": "string, one of: added, modified, removed, confirmed_unchanged", "prior_value": "any, the value before this turn, or null if added", "new_value": "any, the value after this turn, or null if removed", "evidence_source": "string, one of: user_input, retrieved_document, policy_rule, inference, tool_output, explicit_user_correction", "evidence_citation": "string, specific quote or reference from the evidence source", "confidence": "string, one of: high, medium, low", "justification": "string, brief explanation of why this change was made" } ], "unchanged_state_confirmed": [ { "state_path": "string, dot-notation path", "current_value": "any", "confirmation_reason": "string, why this was checked and confirmed unchanged" } ], "pending_items_updated": [ { "item_id": "string", "status": "string, one of: created, resolved, deferred, escalated, cancelled", "description": "string", "evidence": "string" } ], "policy_evaluations": [ { "policy_id": "string, from active policies", "triggered": "boolean", "action_taken": "string or null", "evidence": "string" } ], "risks_flagged": [ { "risk_type": "string, e.g., stale_context, policy_violation, missing_evidence, contradiction", "severity": "string, one of: low, medium, high, critical", "description": "string", "affected_state_paths": ["string"] } ], "completeness_check": { "all_input_fields_processed": "boolean", "all_prior_state_fields_reviewed": "boolean", "missing_evidence_fields": ["string"], "notes": "string" } } } ## CONSTRAINTS - Every state change MUST include a specific evidence citation. Do not cite "model inference" unless no other source exists and you mark confidence as "low". - If the user explicitly corrects a prior assistant claim, you MUST record a "modified" change with evidence_source "explicit_user_correction" and confidence "high". - Timestamps in state_changes must be monotonically increasing within the turn. - If retrieved evidence has a timestamp older than [STALENESS_THRESHOLD_HOURS] hours from the current turn, flag it in risks_flagged with risk_type "stale_context". - Do not invent state paths. Only reference paths that exist in PRIOR_STATE or are explicitly created this turn. - If no state changes occurred, return an empty state_changes array but still populate completeness_check. - Mark confidence as "low" for any change based solely on inference without direct evidence. ## RISK LEVEL: [RISK_LEVEL] - If RISK_LEVEL is "high" or "critical", you MUST populate risks_flagged for any change with confidence "low" or "medium". - If RISK_LEVEL is "critical", you MUST require human review before finalizing any state change with confidence below "high". Indicate this in completeness_check.notes. ## EXAMPLES [FEW_SHOT_EXAMPLES] Generate the audit record now. Return ONLY the JSON object, no other text.
To adapt this template for your application, replace the placeholders with real data at runtime. [PRIOR_STATE] should be the serialized conversation state object from your state management layer, typically a JSON blob tracking slots, intents, pending actions, and policy flags. [RETRIEVED_EVIDENCE] should include the full retrieved document objects with their timestamps and source identifiers, not just the text snippets, so the model can evaluate staleness. [ACTIVE_POLICIES] must include policy IDs and trigger conditions so the model can populate policy_evaluations accurately. For high-risk deployments, set [RISK_LEVEL] to "high" or "critical" and ensure your application layer enforces the human review requirement before persisting any state changes the model flags as low-confidence. The [FEW_SHOT_EXAMPLES] placeholder should contain 2-3 example input-output pairs showing correct audit records for common scenarios: a simple slot fill, a user correction, and a stale-evidence flag. Without examples, the model may hallucinate state paths or misclassify evidence sources.
After receiving the model's output, validate the JSON structure against the schema before persisting the audit record. Run eval checks for completeness: confirm that every field in [PRIOR_STATE] appears in either state_changes or unchanged_state_confirmed, verify that all evidence citations reference actual sources provided in [RETRIEVED_EVIDENCE] or the turn content, and check that timestamps are monotonically increasing. If the completeness_check.all_input_fields_processed or all_prior_state_fields_reviewed fields are false, or if missing_evidence_fields is non-empty, log a warning and consider re-running the prompt with more explicit instructions. Never persist an audit record that fails schema validation or contains hallucinated evidence citations.
Prompt Variables
Required inputs for the Turn-Level State Change Audit Record Prompt. Each placeholder must be populated before the prompt is assembled. Missing or malformed inputs are the most common cause of incomplete audit records.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CURRENT_TURN] | The user or assistant turn that triggered the state change being audited | User: 'Actually, change my shipping address to 456 Oak Ave.' | Must be a single complete turn with speaker label. Reject if empty or spans multiple turns without clear boundary. |
[PRIOR_STATE_SNAPSHOT] | Structured state object from the turn immediately before [CURRENT_TURN] | {"active_slots": {"shipping_address": "123 Elm St"}, "pending_actions": ["confirm_order"]} | Must be valid JSON matching the application state schema. Reject if null or missing required top-level keys. |
[POST_STATE_SNAPSHOT] | Structured state object from the turn immediately after processing [CURRENT_TURN] | {"active_slots": {"shipping_address": "456 Oak Ave"}, "pending_actions": ["confirm_order"]} | Must be valid JSON matching the application state schema. Reject if identical to [PRIOR_STATE_SNAPSHOT] with no change explanation. |
[TURN_METADATA] | Timestamp, turn index, speaker role, and optional confidence scores for the current turn | {"turn_index": 14, "timestamp": "2025-03-15T10:32:11Z", "speaker": "user", "intent_confidence": 0.94} | Must include turn_index as integer, timestamp as ISO-8601, and speaker as 'user' or 'assistant'. Reject if timestamp is earlier than prior turn timestamp. |
[ACTIVE_POLICIES] | List of policy rules or constraints active during this turn that govern state changes | ["POL-003: Address changes require re-verification of payment method", "POL-007: Pending actions persist unless explicitly cancelled"] | Must be a non-empty array of policy strings with identifiers. Reject if any policy ID is not in the approved policy registry. |
[EVIDENCE_SOURCES] | Retrieved documents, tool outputs, or user-provided facts used to justify the state change | [{"source_id": "user_input_t14", "type": "user_correction", "content": "shipping_address=456 Oak Ave"}] | Must be an array of objects with source_id, type, and content. Reject if empty when [POST_STATE_SNAPSHOT] differs from [PRIOR_STATE_SNAPSHOT]. |
[OUTPUT_SCHEMA] | Target JSON schema for the audit record output, defining required fields and types | {"type": "object", "required": ["turn_id", "changes", "justifications"], "properties": {"turn_id": {"type": "string"}}} | Must be valid JSON Schema draft. Reject if schema is missing required fields or contains circular references. |
[CHANGE_TYPE_TAXONOMY] | Allowed change type labels for classifying state mutations in the audit record | ["slot_update", "slot_add", "slot_delete", "pending_action_add", "pending_action_complete", "pending_action_cancel"] | Must be a non-empty array of string labels. Reject if any label contains whitespace or special characters that break downstream enum matching. |
Implementation Harness Notes
How to wire the Turn-Level State Change Audit Record Prompt into a production application with validation, retries, logging, and human review gates.
The Turn-Level State Change Audit Record Prompt is designed to be called after every assistant turn in a conversation pipeline. It should not be called on user turns in isolation—the prompt expects both the user input and the assistant's response to determine what state changed and why. Wire this prompt as a post-processing step in your turn handler, after the assistant response is generated but before the response is sent to the user. This ensures the audit record is captured even if downstream delivery fails. The prompt is stateless by design: it receives the prior state snapshot, the current turn pair, and the system policies as input, and produces a structured change record without relying on any persistent memory of its own.
Validation and retry logic is critical because audit records are downstream dependencies for compliance review, debugging, and state reconstruction. After the prompt returns, validate the output against a JSON schema that enforces: (1) required fields turn_id, timestamp, changed_fields, evidence, and justification; (2) timestamp ordering relative to the prior turn; (3) every entry in changed_fields must reference a field that exists in either the prior or new state snapshot; and (4) evidence must cite specific turn content or policy rules, not generic statements. If validation fails, retry once with the validation errors appended to the prompt as [CONSTRAINTS] feedback. If the retry also fails, log the raw output, flag the turn for human review, and do not block the conversation—audit gaps are better than dropped user experiences. For high-risk domains such as healthcare or finance, route validation failures to a human review queue immediately rather than retrying.
Model choice and latency budgeting matter here. This prompt is not latency-sensitive in the user-facing path because it runs after the assistant response is generated. Use a model with strong instruction-following and JSON output reliability—GPT-4o, Claude 3.5 Sonnet, or equivalent. If cost is a concern, you can run this prompt on a cheaper model (GPT-4o-mini, Claude Haiku) for low-risk conversation types, but validate more aggressively and increase the human-review sampling rate. Logging: store every audit record—both passing and failing—in an append-only audit log with the prompt version, model identifier, raw prompt, raw response, validation result, and any human review decisions. This log becomes your evidence trail for compliance audits and your debugging dataset for prompt improvement. Tool use: this prompt does not call external tools, but the output changed_fields should be consumable by your state management layer to update the canonical session state. Never update canonical state directly from the audit record without validation—the audit record describes what changed, but your state manager owns the authoritative update.
Human review integration should be designed as a sampling gate, not a blocking gate. For most turns, the validated audit record is written to the log and the conversation continues. Configure a sampling rule: 100% of turns where validation failed, 100% of turns in high-risk conversation categories, and X% of all other turns (start with 5-10% and adjust based on your compliance requirements and review capacity). The review interface should display the prior state, the turn transcript, the generated audit record, and any validation warnings side by side. Reviewers should be able to accept, edit, or reject the audit record, and their decisions should be logged with reviewer identity and timestamp. Avoid building a system where human review is required before the conversation can continue—this creates unacceptable latency for users and will be bypassed in practice.
Expected Output Contract
Schema contract for the Turn-Level State Change Audit Record. Every field must be validated before the record is written to the audit log. Missing or malformed fields should trigger a repair retry or human review.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
audit_record_id | string (UUID v4) | Must match UUID v4 regex. Reject on parse failure. | |
turn_sequence_number | integer >= 1 | Must be strictly greater than the previous turn's sequence_number. Reject on non-monotonic or missing value. | |
timestamp_utc | string (ISO 8601) | Must parse as valid ISO 8601 UTC. Must be >= previous turn timestamp. Reject on parse failure or time travel. | |
actor | enum: user | assistant | system | tool | human_override | Must be one of the allowed enum values. Reject on unknown actor. | |
state_change_type | enum: slot_updated | slot_added | slot_deleted | intent_changed | policy_activated | policy_deactivated | commitment_created | commitment_fulfilled | commitment_revoked | context_stale | context_refreshed | correction_applied | escalation_triggered | fallback_activated | clarification_requested | topic_shifted | session_boundary | Must be one of the allowed enum values. Reject on unknown change type. | |
changed_entity_path | string (JSONPath) | Must be a valid JSONPath expression pointing to the changed field in the session state object. Reject on unresolvable path. | |
previous_value | any | null | null allowed for slot_added. Must be present for slot_updated and slot_deleted. Type must match the target field schema. | |
new_value | any | null | null allowed for slot_deleted. Must be present for slot_added and slot_updated. Type must match the target field schema. | |
change_evidence | array of objects | Each evidence object must contain source_turn (integer), source_type (enum: user_utterance | retrieved_document | tool_output | policy_rule | system_instruction), and excerpt (string, max 500 chars). Array must not be empty. Reject on empty evidence or missing source_turn. | |
change_rationale | string (max 1000 chars) | Must be non-empty. Must reference at least one evidence item by source_turn. Reject on empty string or rationale with no evidence reference. | |
policy_citation | string | null | Required if state_change_type is policy_activated or policy_deactivated. Must match a known policy ID from the system policy registry. Reject on unknown policy ID. | |
human_review_required | boolean | Must be true if confidence is low or if state_change_type is escalation_triggered. Reject on false when conditions require review. | |
session_id | string (UUID v4) | Must match UUID v4 regex and match the current session. Reject on mismatch. |
Common Failure Modes
What breaks first when generating turn-level state change audit records and how to guard against it.
Hallucinated State Changes
What to watch: The model invents a state change that never occurred, citing a user turn or tool output that doesn't contain the claimed trigger. This is the most dangerous failure in audit contexts because fabricated records look plausible and erode trust in the entire audit trail. Guardrail: Require the prompt to extract the exact text span or tool output field that justifies each state change. Add a post-generation validation step that verifies the cited evidence exists in the source turn before accepting the record.
Missing State Reversions
What to watch: The user corrects a prior statement or the assistant discovers a tool error, but the audit record fails to log the reversion of dependent state. Later turns operate on stale, invalidated state without any record of the correction. Guardrail: Include explicit instructions to scan for corrections, contradictions, and retractions in the user turn. Add an eval check that compares the state change record against any user corrections detected by a separate correction-detection prompt.
Timestamp Ordering Violations
What to watch: The audit record assigns timestamps that are out of sequence with the conversation order, or uses the generation timestamp instead of the turn timestamp. This breaks downstream replay and compliance review. Guardrail: Require the prompt to use the provided turn timestamp, not generate its own. Add a harness check that validates monotonic timestamp ordering across the full audit sequence and rejects records with future or duplicate timestamps.
Incomplete Justification Chains
What to watch: The record states what changed but omits why, providing only a vague reason like 'user requested' without linking to the specific policy rule, evidence, or prior commitment that drove the change. This fails compliance review. Guardrail: Structure the output schema to require a justification field with sub-fields for triggering condition, cited policy or rule, and supporting evidence. Add an eval that flags records where the justification is fewer than N words or lacks a policy reference.
Schema Drift Across Turns
What to watch: The model changes the field names, types, or structure of the audit record between turns, breaking downstream parsers that expect a consistent schema. This is common in long sessions where the model gradually drifts. Guardrail: Provide a strict JSON schema in the prompt with field descriptions and types. Add a post-generation schema validator that rejects any record that doesn't match the expected schema and triggers a retry with the schema re-emphasized.
Over-Logging Noise Events
What to watch: The model logs every minor conversational nuance as a state change, flooding the audit trail with low-signal records that make it hard to find meaningful changes during review. Guardrail: Define explicit materiality thresholds in the prompt: only log changes to tracked slots, pending actions, policy states, or user intent. Add instructions to skip logging of transient conversational acknowledgments, filler turns, and stylistic variations.
Evaluation Rubric
Criteria for testing the Turn-Level State Change Audit Record Prompt before production deployment. Each criterion targets a specific failure mode identified in state-change auditing.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Change Completeness | Every state field that changed between [PRIOR_STATE] and [NEW_STATE] appears in the audit record with a non-null change_reason | Audit record omits a field that differs between the two state snapshots | Diff [PRIOR_STATE] and [NEW_STATE] keys; assert every differing key has a corresponding entry in the audit record's changed_fields array |
Timestamp Ordering | All change timestamps are monotonically non-decreasing and fall between the prior turn end time and the current turn end time | A change timestamp precedes the prior turn end time or exceeds the current turn end time | Parse all change_timestamp values; assert each is >= [PRIOR_TURN_END] and <= [CURRENT_TURN_END]; assert timestamp[i] <= timestamp[i+1] |
Evidence Grounding | Every change_reason cites at least one specific piece of evidence from [USER_INPUT], [TOOL_OUTPUT], or [RETRIEVED_CONTEXT] | A change_reason contains only generic language with no reference to a concrete source | Regex-check each change_reason for presence of a turn reference, tool call ID, or source citation; flag any reason without a match |
Justification Traceability | For each changed field, the evidence_source field points to a valid turn index or tool call ID present in the conversation context | evidence_source references a turn index that does not exist or a tool call ID that was never made | Collect all turn indices and tool call IDs from the conversation; assert every evidence_source value exists in that set |
No Hallucinated Changes | No state field that is identical between [PRIOR_STATE] and [NEW_STATE] appears in the audit record | Audit record includes a changed_field entry for a key whose value is unchanged between snapshots | For each changed_field in the audit record, assert [PRIOR_STATE][field] != [NEW_STATE][field]; flag any false positive |
Schema Compliance | Output is valid JSON matching the audit record schema with all required fields present and no extra top-level keys | Output fails JSON parse, is missing required fields such as turn_id or changed_fields, or contains unexpected top-level keys | Validate against the audit record JSON schema; assert parse success, required field presence, and no additional properties |
Change Type Classification | Each changed_field includes a change_type from the allowed enum: added, removed, updated, or confirmed | A change_type value is missing, null, or not in the allowed enum set | Assert every changed_field.change_type is non-null and in [added, removed, updated, confirmed] |
Confidence Threshold | Every changed_field has a confidence score >= 0.7 unless explicitly flagged for human review | A changed_field has confidence < 0.7 but human_review_required is false or missing | For each changed_field, if confidence < 0.7, assert human_review_required is true; flag violations |
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 prompt and a single-turn test. Remove strict JSON schema enforcement initially; accept any structured output that contains turn_id, change_type, evidence, and justification. Use a lightweight validator that checks for these four fields only.
Watch for
- Missing
previous_stateandnew_statefields when the model skips the diff - Overly verbose justifications that bury the actual change reason
- Timestamp ordering errors when processing turns out of sequence

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