diff --git a/apps/app/src/app/(app)/[orgId]/policies/[policyId]/editor/components/PolicyDetails.tsx b/apps/app/src/app/(app)/[orgId]/policies/[policyId]/editor/components/PolicyDetails.tsx index d9c0534170..cc784717a5 100644 --- a/apps/app/src/app/(app)/[orgId]/policies/[policyId]/editor/components/PolicyDetails.tsx +++ b/apps/app/src/app/(app)/[orgId]/policies/[policyId]/editor/components/PolicyDetails.tsx @@ -188,8 +188,8 @@ export function PolicyContentManager({
-
-
+
+
@@ -240,7 +240,7 @@ export function PolicyContentManager({
{showAiAssistant && isAiPolicyAssistantEnabled && ( -
+
+
AI Assistant {close && ( @@ -79,7 +79,7 @@ export function PolicyAiAssistant({ )}
- + {messages.length === 0 ? (
diff --git a/apps/app/src/app/api/policies/[policyId]/chat/route.ts b/apps/app/src/app/api/policies/[policyId]/chat/route.ts index 8e17917dc0..1eae9d30e5 100644 --- a/apps/app/src/app/api/policies/[policyId]/chat/route.ts +++ b/apps/app/src/app/api/policies/[policyId]/chat/route.ts @@ -1,10 +1,10 @@ -import { getPolicyTools } from '@/app/(app)/[orgId]/policies/[policyId]/editor/tools/policy-tools'; import { auth } from '@/utils/auth'; import { openai } from '@ai-sdk/openai'; import { db } from '@db'; import { convertToModelMessages, streamText, type UIMessage } from 'ai'; import { headers } from 'next/headers'; import { NextResponse } from 'next/server'; +import { getPolicyTools } from '../../../../(app)/[orgId]/policies/[policyId]/editor/tools/policy-tools'; export const maxDuration = 60; @@ -80,6 +80,8 @@ Current Policy Content: ${policyContentText} --- +IMPORTANT: This assistant is ONLY for editing policies. You MUST always use one of the available tools. + Your role: 1. Edit and improve policies when asked 2. Ensure policies remain compliant with relevant frameworks @@ -99,8 +101,10 @@ COMMUNICATION STYLE: - Be concise and direct - Ask clarifying questions when the user's intent is unclear - One sentence to explain, then act (use tool or ask question) +- Your conversational messages to the user must be plain text only (no markdown headers, bold, italics, bullet points, or code blocks) +- Note: The policy content in proposePolicy tool MUST still use proper markdown formatting -CRITICAL MARKDOWN FORMATTING RULES (when using proposePolicy): +CRITICAL MARKDOWN FORMATTING RULES: - Every heading MUST have text after the # symbols (e.g., "## Section Title", never just "##") - Preserve the original document structure and all sections - Use proper heading hierarchy (# for title, ## for sections, ### for subsections) diff --git a/packages/ui/src/components/ai-elements/conversation.tsx b/packages/ui/src/components/ai-elements/conversation.tsx index bc58b2852f..f553b2070a 100644 --- a/packages/ui/src/components/ai-elements/conversation.tsx +++ b/packages/ui/src/components/ai-elements/conversation.tsx @@ -12,7 +12,7 @@ export type ConversationProps = ComponentProps; export const Conversation = ({ className, ...props }: ConversationProps) => (