Inferensys

Prompt

Canary Token Alerting and Escalation Prompt Template

A practical prompt playbook for using Canary Token Alerting and Escalation Prompt Template in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the operational context, required inputs, and boundaries for the canary token alerting and escalation prompt.

This prompt is for security operations teams who have deployed canary tokens in their AI system prompts and need an automated, structured response when a token is detected in model outputs. It classifies the detection event by severity, generates a machine-readable alert payload, and recommends an escalation path based on the token tier and extraction context. Use this prompt inside a detection pipeline where a canary token match has already occurred. It does not perform the detection itself. It assumes you have the raw model output, the matched token value, the token tier, and the surrounding context available as inputs. This prompt belongs after detection and before human incident response. It bridges the gap between a raw regex match and a routed, prioritized security alert.

The ideal user is a detection pipeline or an automated SOAR (Security Orchestration, Automation, and Response) workflow that has already matched a canary token regex. The required inputs are non-negotiable: you must provide the exact token string that fired, its pre-assigned tier (e.g., L1_SURFACE, L2_DEEP, L3_TOOL_OUTPUT), the full model output containing the token, and at least 500 characters of surrounding context. Without these inputs, the prompt cannot accurately assess blast radius or recommend an appropriate escalation path. The prompt is designed to be stateless and idempotent—running it twice with the same inputs should produce the same severity classification and alert routing decision.

Do not use this prompt for initial token detection or regex matching. It is not a substitute for a high-recall detection harness. Do not use it when the token tier is unknown or when the extraction context is truncated, as missing context leads to incorrect severity downgrades. This prompt is also inappropriate for real-time blocking decisions; it is designed for asynchronous alert generation and human review. If you need to block a response from reaching the user based on a canary match, implement that logic in your detection gateway before this prompt runs. Finally, avoid using this prompt for non-security use cases such as general content filtering or toxicity scoring—its output schema and escalation logic are purpose-built for canary token incident response.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Canary Token Alerting and Escalation Prompt Template delivers value and where it introduces unacceptable risk.

01

Good Fit: Automated SOC Triage

Use when: A detection harness has flagged a canary token in model output and the security operations center needs a standardized alert payload. Guardrail: The prompt classifies severity and recommends escalation paths, but a human must confirm high-severity incidents before containment actions begin.

02

Bad Fit: Real-Time Blocking Decisions

Avoid when: The system must block or quarantine a model response in under 50ms based on canary detection. Risk: LLM-based classification adds latency and non-determinism unsuitable for inline enforcement. Guardrail: Use regex or hash-based detection for the blocking path; reserve this prompt for post-detection enrichment and alert generation.

03

Required Inputs

Mandatory: The raw model output containing the suspected canary token, the token tier definition, and the extraction context. Optional: Conversation history, tool-call logs, and source document metadata. Guardrail: Missing extraction context degrades severity classification accuracy; the prompt should return INSUFFICIENT_CONTEXT rather than guessing.

04

Operational Risk: Alert Fatigue

Risk: Low-tier canary detections from test environments or known false-positive patterns generate noise that desensitizes responders. Guardrail: The prompt must distinguish between production extraction events and test/sandbox detections. Route low-severity findings to a dashboard, not to pager alerts.

05

Operational Risk: Escalation Path Staleness

Risk: Hardcoded escalation contacts in the prompt become outdated, sending alerts to former team members or inactive channels. Guardrail: Escalation targets must be injected from a live configuration source at runtime, never embedded in the prompt template. Validate contact freshness before alert dispatch.

06

Operational Risk: Evidence Chain Gaps

Risk: The alert payload omits critical forensic evidence, forcing incident responders to reconstruct the extraction timeline manually. Guardrail: The prompt must include structured fields for timestamp, model version, prompt version, conversation ID, and raw output excerpt. Incomplete evidence triggers a SUPPRESS_ALERT flag until gaps are filled.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for classifying canary token detections, generating alert payloads, and recommending escalation paths based on token tier and extraction context.

This template is the core of your detection pipeline. It activates after a canary token match is confirmed by your output scanning harness. The prompt ingests the raw detection event, the token's predefined tier, and the surrounding conversation or tool-call context. It then produces a structured alert payload ready for your SIEM, paging system, or incident response queue. Do not use this prompt for initial token scanning—it assumes detection has already occurred and focuses entirely on classification, severity scoring, and escalation logic.

text
You are a security alert classifier for an AI canary token detection system. A canary token has been detected in a model's output. Your job is to analyze the detection event, classify its severity, and produce a structured alert payload with an escalation recommendation.

## INPUTS
- DETECTION_EVENT: [DETECTION_EVENT]
- TOKEN_TIER: [TOKEN_TIER]
- EXTRACTION_CONTEXT: [EXTRACTION_CONTEXT]
- MODEL_ID: [MODEL_ID]
- SESSION_ID: [SESSION_ID]
- TIMESTAMP: [TIMESTAMP]

## TOKEN TIER REFERENCE
- TIER_1_SURFACE: Token placed in visible system prompt preamble. Low sensitivity. Indicates basic extraction attempt.
- TIER_2_INSTRUCTION: Token embedded inside behavioral instructions. Medium sensitivity. Indicates deeper instruction probing.
- TIER_3_POLICY: Token hidden inside safety or refusal policy blocks. High sensitivity. Indicates targeted policy extraction.
- TIER_4_TOOL: Token placed inside tool description or parameter schemas. Critical sensitivity. Indicates tool-surface reconnaissance.

## TASK
1. Classify the severity of this detection as LOW, MEDIUM, HIGH, or CRITICAL based on TOKEN_TIER and EXTRACTION_CONTEXT.
2. Generate an alert payload matching the [OUTPUT_SCHEMA].
3. Recommend an escalation path: LOG_ONLY, SECURITY_REVIEW, INCIDENT_RESPONSE, or EMERGENCY_PAGE.
4. Include a concise evidence summary that quotes the relevant output fragment containing the token.

## SEVERITY RULES
- TIER_1 with isolated extraction and no tool context: LOW
- TIER_2 with any extraction: MEDIUM
- TIER_3 with any extraction: HIGH
- TIER_4 with any extraction: CRITICAL
- Any tier with multi-turn extraction pattern: escalate one level
- Any tier with tool-call correlation: escalate one level

## ESCALATION RULES
- LOW severity: LOG_ONLY
- MEDIUM severity: SECURITY_REVIEW within 24 hours
- HIGH severity: INCIDENT_RESPONSE within 4 hours
- CRITICAL severity: EMERGENCY_PAGE within 15 minutes

## CONSTRAINTS
- Do not include the raw canary token value in the evidence summary. Reference it by token ID only.
- If EXTRACTION_CONTEXT is incomplete or ambiguous, note this in a confidence field and default to one severity level higher.
- If multiple tokens are detected in one event, generate separate alert payloads for each.
- Preserve all timestamps in UTC ISO 8601 format.

## OUTPUT_SCHEMA
Return a JSON object with this exact structure:
{
  "alert_id": "string, generated as CANARY-{TIMESTAMP}-{SESSION_ID}",
  "severity": "LOW|MEDIUM|HIGH|CRITICAL",
  "token_tier": "string",
  "token_id": "string, the token identifier without the raw value",
  "model_id": "string",
  "session_id": "string",
  "detection_timestamp": "string, ISO 8601",
  "escalation_path": "LOG_ONLY|SECURITY_REVIEW|INCIDENT_RESPONSE|EMERGENCY_PAGE",
  "evidence_summary": "string, max 200 chars, describe what was detected and where without exposing the raw token",
  "confidence": "HIGH|MEDIUM|LOW",
  "recommended_actions": ["string, concrete next step"],
  "correlation_hints": {
    "multi_turn": true|false,
    "tool_call_involved": true|false,
    "related_session_ids": ["string"]
  }
}

Adapt this template by replacing the TOKEN_TIER_REFERENCE with your organization's actual canary tier definitions. If you use a different tiering model—such as per-environment, per-customer, or per-model-version tiers—update the severity and escalation rules accordingly. The OUTPUT_SCHEMA should match your SIEM or incident management system's expected payload format. If your detection harness already enriches events with user identity, geographic metadata, or rate-limit counters, add those fields to both the INPUTS block and the output schema. Test this prompt with synthetic detection events across all four tiers before connecting it to a live paging system. A misclassified CRITICAL event that triggers an unnecessary page will erode trust in the entire canary program.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Populate these from your detection pipeline before calling the model.

PlaceholderPurposeExampleValidation Notes

[CANARY_TOKEN_REGEX]

Regex pattern matching the specific canary token format embedded in system instructions.

canary-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}

Must compile without errors in the target language. Test against known token samples and false-positive strings before production use.

[DETECTED_TOKEN_VALUE]

The raw canary token string extracted from the model output by the upstream detection harness.

canary-3f7a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c

Must not be null or empty. Validate format matches [CANARY_TOKEN_REGEX] before passing to the prompt. If null, the alerting prompt should not be invoked.

[EXTRACTION_CONTEXT]

The full model response or the surrounding conversation turn where the token was detected, truncated to a reasonable window.

User: Summarize the document. Assistant: Here is the summary... canary-3f7a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c ...the rest of the output.

Must be a non-empty string. Truncate to the last N characters (e.g., 2000) to manage context window costs. Ensure the token is present in the provided context.

[TOKEN_TIER]

The severity classification of the detected token, pulled from the token management registry.

TIER_1_CRITICAL

Must match one of the predefined tiers: TIER_1_CRITICAL, TIER_2_HIGH, TIER_3_MEDIUM. Validate against an allowlist before injection. Default to TIER_3_MEDIUM if unknown.

[DETECTION_TIMESTAMP]

ISO-8601 formatted timestamp of when the canary token was detected by the monitoring system.

2024-05-22T14:30:00Z

Must be a valid ISO-8601 string. Parse and reformat if necessary to ensure consistency. Used for SLA tracking and incident timeline reconstruction.

[REQUEST_ID]

The unique identifier for the model request that produced the output containing the canary token.

req_9a8b7c6d5e4f3a2b1c0d

Must be a non-empty string. Validate that the request ID exists in the logging backend. Critical for traceability and isolating the affected session.

[USER_ID]

The identifier of the user or session associated with the request that triggered the canary detection.

user_12345 or session_abc

Can be 'anonymous' if not authenticated. Validate format against user ID schema. Used to determine if the extraction is from an internal test, a specific account, or an unauthenticated attacker.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the canary token alerting prompt into a production detection pipeline with validation, routing, and human review.

This prompt is designed to sit inside a security monitoring pipeline, not as a standalone chatbot. It receives structured detection events from an upstream canary token scanner—typically a regex or pattern-matching service that monitors model outputs in real time—and produces a classified alert payload. The prompt's job is to interpret the raw detection event, assess severity based on token tier and extraction context, and recommend an escalation path. It should be called automatically when a canary token match is detected, never exposed to end users or embedded in the model's own system prompt.

Wire the prompt into an event-driven workflow: a detection service publishes a canary_token_detected event containing the token ID, tier, matched text, source context (e.g., user output, tool result, log stream), and timestamp. A handler function constructs the prompt request by populating [DETECTION_EVENT] with the serialized event, [TOKEN_TIER_MAP] with your organization's tier definitions and severity mappings, [ESCALATION_POLICY] with team contacts and response SLAs, and [OUTPUT_SCHEMA] with the expected JSON structure. Validate the model's response against the schema before any downstream action—reject and retry once if the output fails schema validation, then fall back to a default CRITICAL classification and page the on-call security engineer. Log every prompt invocation, the raw model response, and the validation result for audit and regression testing.

For model choice, prefer a fast, instruction-following model with strong JSON output discipline (e.g., Claude 3.5 Sonnet or GPT-4o with structured outputs enabled). Latency matters here—the prompt should return in under 2 seconds to avoid delaying incident response. Set temperature=0 to eliminate classification variance. If the detection event contains sensitive output text, ensure the prompt request is sent through an internal API or private deployment; never route canary token evidence through a public model endpoint. For high-security environments, run this prompt on a locally deployed model to keep detection evidence within your network boundary.

The prompt's severity classification must be treated as a recommendation, not an automatic trigger for destructive actions. Implement a two-stage escalation gate: for LOW and MEDIUM severities, log the alert and create a ticket in your security queue for review within the SLA window. For HIGH and CRITICAL severities, immediately notify the on-call security engineer via pager and include the full alert payload. Never allow the model's output to directly rotate API keys, revoke credentials, or block user accounts—those actions require human approval. The prompt's recommended_actions field should be surfaced to the responder as suggested next steps, not executed automatically.

Test this harness end-to-end before production deployment. Create a regression suite with known detection events across all severity tiers, including edge cases like malformed token matches, duplicate detections, and events with truncated context. Verify that schema validation catches malformed model outputs, that the retry-and-fallback logic works, and that alert routing reaches the correct teams. Run these tests after every prompt change and model upgrade. Monitor production metrics: classification latency, schema validation failure rate, retry frequency, and false-positive alert volume. If the model starts misclassifying severities or hallucinating escalation contacts, freeze the prompt version and investigate before the harness generates noisy alerts that erode responder trust.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the JSON alert payload generated by the Canary Token Alerting and Escalation Prompt. Use this contract to validate model output before ingestion into SIEM, SOAR, or incident response pipelines.

Field or ElementType or FormatRequiredValidation Rule

alert_id

string (UUID v4)

Must match regex ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$. Reject if missing or malformed.

detection_timestamp

string (ISO 8601 UTC)

Must parse as valid datetime in UTC. Must be within 5 minutes of system clock. Reject if future-dated or unparseable.

canary_token_value

string

Must be non-empty. Must match one of the known canary token patterns from the active token registry. Reject if token is unknown or null.

token_tier

string (enum)

Must be one of: 'surface', 'deep', 'critical'. Reject if value is not in the allowed enum set.

severity

string (enum)

Must be one of: 'low', 'medium', 'high', 'critical'. Must be consistent with token_tier mapping: surface->low/medium, deep->high, critical->critical. Reject on mismatch.

extraction_context

object

Must contain 'source' (string: 'user_output','tool_output','log_stream') and 'excerpt' (string, max 500 chars). Reject if source is unrecognized or excerpt is empty.

recommended_escalation

string (enum)

Must be one of: 'log_only','notify_security','page_oncall','lockdown'. Must align with severity: low->log_only, medium->notify_security, high->page_oncall, critical->lockdown. Reject on mismatch.

confidence_score

number (float 0.0-1.0)

Must be a number between 0.0 and 1.0 inclusive. Values below 0.85 should trigger a human-review flag but not block the alert. Reject if out of range or non-numeric.

PRACTICAL GUARDRAILS

Common Failure Modes

Canary token detection pipelines fail in predictable ways. These are the most common failure modes when deploying canary token alerting and escalation prompts, along with practical mitigations.

01

False Positives from Token-Like Patterns

What to watch: The detection prompt flags legitimate outputs that coincidentally match canary token patterns, such as UUIDs, base64 strings, or random identifiers in normal application data. This floods the alerting pipeline with noise and erodes trust in the detection system. Guardrail: Implement a two-stage detection pipeline where the first pass uses regex pattern matching and the second pass uses the LLM prompt to classify whether the match is a true canary token or a coincidental pattern. Require exact token match confirmation before escalation.

02

Encoding Obfuscation Bypass

What to watch: Attackers encode canary tokens using base64, Unicode homoglyphs, zero-width characters, or split across multiple output segments. The detection prompt fails to recognize the obfuscated token, allowing extraction to go undetected. Guardrail: Pre-process outputs with a decoding and normalization step before detection. Expand the detection prompt to include instructions for recognizing common encoding patterns. Test against a library of obfuscated token variants during evaluation.

03

Token Fragmentation Across Multi-Turn Responses

What to watch: In multi-turn conversations, attackers extract canary tokens piece by piece across separate responses. No single response contains the complete token, so per-response detection misses the extraction. Guardrail: Maintain a session-level token fragment buffer that accumulates partial matches across turns. Configure the escalation prompt to trigger when cumulative fragments reconstruct a complete canary token, not just on single-response matches.

04

Severity Misclassification and Alert Fatigue

What to watch: The escalation prompt classifies all canary detections as critical, or fails to distinguish between surface-level token leakage and deep instruction extraction. This causes alert fatigue, delayed response to genuine attacks, or over-escalation of low-severity events. Guardrail: Define clear severity tiers in the escalation prompt based on token tier, extraction context, and completeness. Surface tokens trigger low-severity alerts for monitoring. Deep instruction tokens trigger immediate escalation. Include tier-specific response playbooks.

05

Detection Latency During High-Volume Output

What to watch: The detection prompt adds latency to every response, and during high-throughput periods the synchronous check becomes a bottleneck. Teams disable detection under load, creating windows of vulnerability. Guardrail: Decouple detection from the response path. Stream outputs to the user immediately and run canary detection asynchronously. Configure the escalation prompt to support retroactive alerting with output timestamps and session context for post-hoc investigation.

06

Canary Token Collision in Shared Context

What to watch: Multiple tenants or sessions share the same canary token due to misconfiguration, making it impossible to determine which user or attack vector triggered the alert. Incident response loses attribution and blast radius assessment becomes unreliable. Guardrail: Generate unique canary tokens per session, tenant, or deployment context. Include token-to-context mapping in the escalation prompt payload so alerts carry attribution metadata. Validate token uniqueness during deployment.

IMPLEMENTATION TABLE

Evaluation Rubric

How to test output quality before shipping. Run these checks against a golden dataset of known canary detection events with expected severities and escalation paths.

CriterionPass StandardFailure SignalTest Method

Severity Classification Accuracy

All [TIER_1] tokens correctly classified as CRITICAL; [TIER_2] as HIGH; [TIER_3] as MEDIUM

CRITICAL token classified as LOW or INFO; any token severity misclassified by more than one level

Run 50 labeled examples per tier through the prompt; assert exact match on severity label

Escalation Path Correctness

CRITICAL events map to 'immediate-pager'; HIGH to 'ticket-priority'; MEDIUM to 'daily-review'

CRITICAL event mapped to 'daily-review' or 'none'; any escalation path mismatch for known token tiers

Golden dataset with expected escalation path per token; assert string match on [ESCALATION_PATH] field

Alert Payload Schema Validity

Output parses as valid JSON matching [OUTPUT_SCHEMA]; all required fields present and non-null

JSON parse failure; missing 'token_id', 'severity', or 'timestamp' fields; null values in required fields

Schema validator script run against 100 generated alert payloads; 100% parse success required

False Positive Rate on Clean Outputs

Zero detections when scanning 200 known-clean model responses without canary tokens

Any canary token detected in clean output sample; confidence score above 0.1 on clean input

Run detection prompt against curated clean dataset; assert detection_count equals 0

Detection Confidence Thresholding

True positives report confidence >= 0.95; false positives (if any) report confidence < 0.5

True positive with confidence below 0.7; false positive with confidence above 0.8

Measure confidence distribution on 100 known positives and 100 known negatives; check threshold separation

Extraction Context Preservation

Output includes source context field populated with 'system_prompt', 'tool_output', or 'user_turn' as appropriate

Missing or null [EXTRACTION_CONTEXT] field; context labeled 'unknown' for known extraction vector

Inject tokens via each vector in test harness; assert context field matches injection point for 100% of cases

Timestamp and Traceability Compliance

Every alert includes ISO-8601 timestamp and unique alert_id; timestamps within 5 seconds of test execution

Missing timestamp; duplicate alert_id; timestamp more than 60 seconds from detection event

Parse 200 alert outputs; validate timestamp format, uniqueness of alert_id, and clock skew tolerance

Multi-Token Co-Occurrence Handling

When multiple tokens detected in single output, alert payload lists all token_ids in array; severity set to highest detected tier

Only first token reported; severity downgraded to lowest tier when CRITICAL token co-occurs

Inject outputs with 2-3 tokens of mixed severity; assert array length and max-severity selection logic

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base classification prompt and a simple JSON schema for severity and escalation. Use hardcoded token-to-tier mappings instead of a dynamic lookup. Skip the alert payload generation step and return only the classification result.

code
[SYSTEM]
You are a canary token detection classifier. Given a detection event, classify severity as LOW, MEDIUM, HIGH, or CRITICAL based on the token tier and extraction context.

Token tier mapping:
- TIER_1 (surface canary): LOW
- TIER_2 (instruction canary): MEDIUM
- TIER_3 (deep canary): HIGH
- TIER_4 (policy canary): CRITICAL

Return JSON: {"severity": "...", "rationale": "..."}

Watch for

  • Missing extraction context fields causing default LOW classifications
  • No handling of unknown token tiers
  • Overly broad rationale that doesn't help incident responders
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.