Skip to content

Open-source status page, incident response and uptime monitoring

fix date hallucination (#1942)

Thibault Le Ouay066eba6f75e7
diff --git a/apps/server/src/routes/slack/agent.test.ts b/apps/server/src/routes/slack/agent.test.ts
new file mode 100644
index 000000000..c0d6df997
--- /dev/null
+++ b/apps/server/src/routes/slack/agent.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, test } from "bun:test";
+import { buildSystemPrompt } from "./agent";
+
+describe("buildSystemPrompt", () => {
+ test("includes the current date and time in ISO 8601 format", () => {
+ const before = new Date();
+ const prompt = buildSystemPrompt("My Workspace");
+ const after = new Date();
+
+ const match = prompt.match(
+ /The current date and time is: (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z) \(UTC\)/,
+ );
+ expect(match).not.toBeNull();
+
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
+ const promptDate = new Date(match![1]);
+ expect(promptDate.getTime()).toBeGreaterThanOrEqual(before.getTime());
+ expect(promptDate.getTime()).toBeLessThanOrEqual(after.getTime());
+ });
+
+ test("includes the workspace name", () => {
+ const prompt = buildSystemPrompt("Acme Corp");
+ expect(prompt).toContain('workspace "Acme Corp"');
+ });
+});
diff --git a/apps/server/src/routes/slack/agent.ts b/apps/server/src/routes/slack/agent.ts
index 2fcc20bda..e06b0bf97 100644
--- a/apps/server/src/routes/slack/agent.ts
+++ b/apps/server/src/routes/slack/agent.ts
@@ -14,8 +14,10 @@ interface AgentResult {
toolResults: Array<{ toolName: string; result: unknown }>;
}
-function buildSystemPrompt(workspaceName: string): string {
+export function buildSystemPrompt(workspaceName: string): string {
+ const now = new Date().toISOString();
return `You are the OpenStatus assistant for workspace "${workspaceName}".
+The current date and time is: ${now} (UTC).
You help teams create and manage status reports and maintenance windows through Slack.
IMPORTANT: You have NO knowledge of this workspace's data. NEVER guess or make up IDs (page IDs, component IDs, report IDs). You MUST call the appropriate tool first to get real data.
diff --git a/apps/server/src/routes/slack/blocks.ts b/apps/server/src/routes/slack/blocks.ts
index db91e8a12..32bb83dbb 100644
--- a/apps/server/src/routes/slack/blocks.ts
+++ b/apps/server/src/routes/slack/blocks.ts
@@ -239,6 +239,7 @@ function formatDate(iso: string): string {
if (Number.isNaN(d.getTime())) return iso;
return d.toLocaleString("en-US", {
weekday: "short",
+ year: "numeric",
month: "short",
day: "numeric",
hour: "numeric",