@@ -1,6 +1,6 @@
11 import { NextResponse } from "next/server";
22 import { db } from "@/src/lib/db";
3-import { threads } from "@/src/lib/db/schema";
3+import { threads, messages } from "@/src/lib/db/schema";
44 import { desc, count } from "drizzle-orm";
55
66 export async function POST(request: Request) {
@@ -15,6 +15,20 @@ export async function POST(request: Request) {
1515 })
1616 .returning();
1717
18+ const threadId = newThread[0].id;
19+
20+ // Insert system message with guidelines
21+ await db.insert(messages).values({
22+ threadId,
23+ role: "system",
24+ content: `You are PAT, a helpful assistant. Please follow these guidelines:
25+- Tool calls should not be used more than once per user request
26+- Use simple and concise language
27+- Reply with markdown whenever possible
28+- When asked for code or text return it in a markdown code block`,
29+ createdAt: new Date(),
30+ });
31+
1832 return NextResponse.json({ thread: newThread[0] });
1933 } catch (error) {
2034 console.error("Create thread error", error);