Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): always include task attribution (#90999)

Jonathan Mieloo0279b40f2d18
diff --git a/products/desktop/packages/agent/src/pi/task-system-prompt.test.ts b/products/desktop/packages/agent/src/pi/task-system-prompt.test.ts
index e0a8826de775..29abc3fb5fac 100644
--- a/products/desktop/packages/agent/src/pi/task-system-prompt.test.ts
+++ b/products/desktop/packages/agent/src/pi/task-system-prompt.test.ts
@@ -24,7 +24,7 @@ describe("buildTaskSystemPrompt", () => {
expect(prompt).toContain("## Channel task");
});
- it("does not give local source-control instructions to cloud tasks", () => {
+ it("includes signed commit attribution instructions for cloud tasks", () => {
const prompt = buildTaskSystemPrompt({
projectId: 42,
apiHost: "https://us.posthog.com",
@@ -34,7 +34,10 @@ describe("buildTaskSystemPrompt", () => {
additionalInstructions: "Use the existing pull request.",
});
- expect(prompt).not.toContain("Generated-By: PostHog Desktop");
+ expect(prompt).toContain("git_signed_commit");
+ expect(prompt).toContain("Generated-By: PostHog Desktop");
+ expect(prompt).toContain("Task-Id: task-123");
+ expect(prompt).not.toContain('git commit -m "$(cat');
expect(prompt).toContain("Use the existing pull request.");
});
});
diff --git a/products/desktop/packages/agent/src/pi/task-system-prompt.ts b/products/desktop/packages/agent/src/pi/task-system-prompt.ts
index 1fb6992844ef..1cd54dc42bec 100644
--- a/products/desktop/packages/agent/src/pi/task-system-prompt.ts
+++ b/products/desktop/packages/agent/src/pi/task-system-prompt.ts
@@ -36,11 +36,16 @@ export function buildTaskContextPrompt(taskId: string): string {
This is task ${taskId}. Keep material provided as task context, including customer conversations, support tickets, logs, and internal threads, out of code, tests, comments, commit messages, and pull request text. Rewriting or anonymizing that material does not make it safe to publish.`;
}
-export function buildLocalAttributionPrompt(taskId: string): string {
- return `## Attribution
-Do NOT use Claude Code's default attribution (no "Co-Authored-By" trailers, no "Generated with [Claude Code]" lines).
-
-Instead, add the following trailers to EVERY commit message (after a blank line at the end):
+export function buildAttributionPrompt(
+ taskId: string,
+ environment: TaskContext["environment"],
+): string {
+ const commitInstructions =
+ environment === "cloud"
+ ? `In cloud tasks, call \`git_signed_commit\` to create commits. It automatically adds these trailers:
+ Generated-By: PostHog Desktop
+ Task-Id: ${taskId}`
+ : `Add the following trailers to every commit message after a blank line:
Generated-By: PostHog Desktop
Task-Id: ${taskId}
@@ -53,7 +58,12 @@ Generated-By: PostHog Desktop
Task-Id: ${taskId}
EOF
)"
-\`\`\`
+\`\`\``;
+
+ return `## Attribution
+Do NOT use Claude Code's default attribution (no "Co-Authored-By" trailers, no "Generated with [Claude Code]" lines).
+
+${commitInstructions}
When creating new branches, prefix them with \`posthog/\` (e.g. \`posthog/fix-login-redirect\`).
@@ -64,6 +74,10 @@ When creating pull requests, add the following footer at the end of the PR descr
\`\`\``;
}
+export function buildLocalAttributionPrompt(taskId: string): string {
+ return buildAttributionPrompt(taskId, "local");
+}
+
export function buildQuestionsPrompt(
structuredInputAvailable: boolean,
): string {
@@ -134,11 +148,8 @@ export function buildTaskSystemPrompt(
buildTaskContextPrompt(context.taskId),
];
- if (context.environment === "local") {
- sections.push(buildLocalAttributionPrompt(context.taskId));
- }
-
sections.push(
+ buildAttributionPrompt(context.taskId, context.environment),
buildQuestionsPrompt(capabilities.structuredInput === true),
buildPullRequestLinksPrompt(),
buildShellEfficiencyPrompt(),