:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
export const roleMap: Record<string, string> = {
user: 'user',
human: 'user',
assistant: 'assistant',
model: 'assistant',
ai: 'assistant',
bot: 'assistant',
system: 'system',
instructions: 'system',
context: 'system',
}
export function normalizeRole(rawRole: unknown, fallback: string): string {
if (typeof rawRole !== 'string') {
return fallback
}
const lowercased = rawRole.toLowerCase()
return roleMap[lowercased] || lowercased
}
// Synthetic role used to surface the `$ai_tools` payload as a pseudo-message
export const AVAILABLE_TOOLS_ROLE = 'available tools'