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 = `