Markdown Converter
Agent skill for markdown-converter
This page explains how to use the genai_extract_system_prompt function in APL.
Sign in to like and favorite skills
The
genai_extract_system_prompt function extracts the system prompt from a GenAI messages array. The system prompt typically contains instructions that define the AI assistant’s behavior, personality, and capabilities. It’s usually the first message with role 'system'.
You can use this function to audit AI behavior configurations, monitor prompt changes, analyze consistency across conversations, or validate that correct system instructions are being used.
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
In Splunk SPL, you would need to filter messages by role and extract the first system message.
['ai-logs'] | extend system_prompt = genai_extract_system_prompt(messages)
In ANSI SQL, you would unnest the array and filter for the first system role message.
['ai-logs'] | extend system_prompt = genai_extract_system_prompt(messages)
genai_extract_system_prompt(messages)
| Name | Type | Required | Description |
|---|---|---|---|
| messages | dynamic | Yes | An array of message objects from a GenAI conversation. Each message typically contains and fields. |
Returns a string containing the content of the system message, or an empty string if no system message is found.
Extract the system prompt from a GenAI conversation to verify AI configuration.
Query
['genai-traces'] | extend system_prompt = genai_extract_system_prompt(['attributes.gen_ai.input.messages']) | where isnotempty(system_prompt) | summarize conversation_count = count() by system_prompt | top 3 by conversation_count
Output
| system_prompt | conversation_count |
|---|---|
| You are a helpful customer service assistant. | 1250 |
| You are a technical support expert specializing in software troubleshooting. | 845 |
This query helps you understand which system prompts are most commonly used and track prompt variations.