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(agent): keep the task id out of the cloud system prompt (#116256)

Julian Bez843aa8291680
diff --git a/packages/agent/packages/agent/src/server/agent-server.test.ts b/packages/agent/packages/agent/src/server/agent-server.test.ts
index 7917e8defd78..4eb1389681be 100644
--- a/packages/agent/packages/agent/src/server/agent-server.test.ts
+++ b/packages/agent/packages/agent/src/server/agent-server.test.ts
@@ -7071,7 +7071,7 @@ describe("AgentServer HTTP Mode", () => {
expect(prompt).not.toContain("gh pr checkout");
expect(prompt).not.toContain("Create a draft pull request");
expect(prompt).toContain("Generated-By: PostHog Desktop");
- expect(prompt).toContain("Task-Id: test-task-id");
+ expect(prompt).not.toContain("test-task-id");
});
it("returns default prompt when no prUrl", () => {
@@ -7082,7 +7082,7 @@ describe("AgentServer HTTP Mode", () => {
"Do NOT create a branch, commit, push, or open a pull request unless the user explicitly asks.",
);
expect(prompt).toContain("Generated-By: PostHog Desktop");
- expect(prompt).toContain("Task-Id: test-task-id");
+ expect(prompt).not.toContain("test-task-id");
expect(prompt).not.toContain("gh pr create --draft");
// If the user does explicitly ask for a PR in this review-first mode,
// the agent must still use the PostHog Desktop footer, not Claude Code's default.
@@ -7126,7 +7126,7 @@ describe("AgentServer HTTP Mode", () => {
"gh issue list --search",
"Closes #<n>",
"Generated-By: PostHog Desktop",
- "Task-Id: test-task-id",
+ "a `Task-Id` trailer",
"canonical `posthog:exec` tool",
"`posthog:business-knowledge-documents-search`",
"whatever else the question is about",
@@ -7198,7 +7198,7 @@ describe("AgentServer HTTP Mode", () => {
expect(prompt).toContain("Create a draft pull request");
expect(prompt).toContain("gh pr create --draft");
expect(prompt).toContain("Generated-By: PostHog Desktop");
- expect(prompt).toContain("Task-Id: test-task-id");
+ expect(prompt).not.toContain("test-task-id");
// Slack-origin PRs are attributed to PostHog, not the PostHog Desktop app.
expect(prompt).toContain(
"Created with [PostHog](https://posthog.com?ref=pr)",
diff --git a/packages/agent/packages/harness/src/extensions/task-system-prompt/cloud.ts b/packages/agent/packages/harness/src/extensions/task-system-prompt/cloud.ts
index 191d633dcfeb..b690f18830d4 100644
--- a/packages/agent/packages/harness/src/extensions/task-system-prompt/cloud.ts
+++ b/packages/agent/packages/harness/src/extensions/task-system-prompt/cloud.ts
@@ -143,12 +143,14 @@ You do not have GitHub access in this session.
- Do not guess file contents. Do not start a change that you cannot deliver.`;
}
+ // Keep the task id and other per-task values out of this prompt. Sibling tasks, such as the
+ // parallel sessions of one ReviewHog review, then send the same prefix, and the provider serves
+ // it from its prompt cache. A per-task value breaks the cache for every token after it.
buildCloudSystemPrompt(
prUrl?: string | null,
slackThreadUrl?: string | null,
inboxReportUrl?: string | null,
): string {
- const taskId = this.options.taskId;
const shouldAutoCreatePr = this.options.shouldAutoPublish;
const isSlack = this.options.isSlack;
// Every instruction in this section runs through `gh`, so a sandbox holding no
@@ -244,9 +246,7 @@ hard reset is the safe one here — your work is held in the stash.
## Attribution
Do NOT add "Co-Authored-By" trailers or "Generated with [Claude Code]" lines to your
commit messages. The \`git_signed_commit\` tool automatically appends the only trailers
-we want:
-Generated-By: PostHog Desktop
-Task-Id: ${taskId}`;
+we want: \`Generated-By: PostHog Desktop\` and a \`Task-Id\` trailer with this task's id.`;
// A stack is several PRs, so this would contradict the review-first modes.
const stackInstructions = shouldAutoCreatePr