From ef139eefa71fe3674c99e4bc651353c4ae64e3d6 Mon Sep 17 00:00:00 2001 From: Joshua Snyder Date: Fri, 5 Jun 2026 23:53:17 +0100 Subject: [PATCH] fix(agent): tell Slack app not to wrap links in bold The Slack app frequently emits messages like `*`, wrapping URLs in bold. In Slack mrkdwn bold is a single asterisk pair, so the trailing `*` attaches to the URL and breaks the link when opened in a browser. Add a "Slack formatting" section to the Slack-origin identity system prompt instructing the agent to never wrap URLs/links in bold or other formatting, to use `` for labeled links, and that bold is a single (not double) asterisk pair. Generated-By: PostHog Code Task-Id: f64ca0d9-fab3-49ff-9989-84a971f1a311 --- packages/agent/src/server/agent-server.test.ts | 4 ++++ packages/agent/src/server/agent-server.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/agent/src/server/agent-server.test.ts b/packages/agent/src/server/agent-server.test.ts index b01db26433..52371fc864 100644 --- a/packages/agent/src/server/agent-server.test.ts +++ b/packages/agent/src/server/agent-server.test.ts @@ -1422,6 +1422,10 @@ describe("AgentServer HTTP Mode", () => { expect(prompt).toContain("# Identity"); expect(prompt).toContain("PostHog Slack app"); expect(prompt).toContain("Do NOT refer to yourself as Claude"); + expect(prompt).toContain("# Slack formatting"); + expect(prompt).toContain( + "NEVER wrap a URL or link in bold or any other formatting", + ); delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN; }, ); diff --git a/packages/agent/src/server/agent-server.ts b/packages/agent/src/server/agent-server.ts index 9b247a9916..746d3a2725 100644 --- a/packages/agent/src/server/agent-server.ts +++ b/packages/agent/src/server/agent-server.ts @@ -1692,6 +1692,12 @@ export class AgentServer { ? ` # Identity You are the PostHog Slack app, PostHog's agent for helping users with their product data and coding tasks from Slack. When introducing yourself or referring to yourself in messages to the user, identify as "PostHog Slack app". Do NOT refer to yourself as Claude, an Anthropic assistant, or any underlying model name. + +# Slack formatting +Your messages are rendered as Slack mrkdwn, not GitHub Markdown. +- NEVER wrap a URL or link in bold or any other formatting. Bold uses single asterisks in Slack (\`*bold*\`), so a URL inside \`*...*\` puts an asterisk directly against the link and breaks it (e.g. \`*https://example.com*\` opens as \`https://example.com*\`). Always write bare URLs with no surrounding \`*\`, \`_\`, or backticks — e.g. write \`https://github.com/org/repo/pull/1\`, never \`*https://github.com/org/repo/pull/1*\`. +- For a labeled link use Slack's \`\` syntax, again with no formatting wrapped around it. +- Bold is a single asterisk pair (\`*text*\`), not double (\`**text**\`). Use it for short labels only, never around links. ` : ""; const signedCommitInstructions = `