@posthog/agent 2.3.145 → 2.3.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/agent",
3
- "version": "2.3.145",
3
+ "version": "2.3.155",
4
4
  "repository": "https://github.com/PostHog/code",
5
5
  "description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
6
6
  "exports": {
@@ -67,6 +67,7 @@ import {
67
67
  getEffortOptions,
68
68
  resolveModelPreference,
69
69
  supports1MContext,
70
+ supportsMcpInjection,
70
71
  toSdkModelId,
71
72
  } from "./session/models";
72
73
  import {
@@ -797,7 +798,11 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
797
798
  const settingsManager = new SettingsManager(cwd);
798
799
  await settingsManager.initialize();
799
800
 
800
- const mcpServers = parseMcpServers(params);
801
+ const earlyModelId =
802
+ settingsManager.getSettings().model || meta?.model || "";
803
+ const mcpServers = supportsMcpInjection(earlyModelId)
804
+ ? parseMcpServers(params)
805
+ : {};
801
806
  const systemPrompt = buildSystemPrompt(meta?.systemPrompt);
802
807
 
803
808
  this.logger.info(isResume ? "Resuming session" : "Creating new session", {
@@ -37,6 +37,12 @@ export function supportsMaxEffort(modelId: string): boolean {
37
37
  return MODELS_WITH_MAX_EFFORT.has(modelId);
38
38
  }
39
39
 
40
+ const MODELS_TO_EXCLUDE_MCP_TOOLS = new Set(["claude-haiku-4-5"]);
41
+
42
+ export function supportsMcpInjection(modelId: string): boolean {
43
+ return !MODELS_TO_EXCLUDE_MCP_TOOLS.has(modelId);
44
+ }
45
+
40
46
  interface EffortOption {
41
47
  value: string;
42
48
  name: string;
@@ -365,14 +365,19 @@ describe("AgentServer HTTP Mode", () => {
365
365
  expect(prompt).toContain("https://github.com/org/repo/pull/1");
366
366
  expect(prompt).toContain("gh pr checkout");
367
367
  expect(prompt).not.toContain("Create a draft pull request");
368
+ expect(prompt).toContain("Generated-By: PostHog Code");
369
+ expect(prompt).toContain("Task-Id: test-task-id");
368
370
  });
369
371
 
370
372
  it("returns default prompt when no prUrl", () => {
371
373
  const s = createServer();
372
374
  const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt();
373
- expect(prompt).toContain("Create a new branch");
375
+ expect(prompt).toContain("posthog-code/");
374
376
  expect(prompt).toContain("Create a draft pull request");
375
377
  expect(prompt).toContain("gh pr create --draft");
378
+ expect(prompt).toContain("Generated-By: PostHog Code");
379
+ expect(prompt).toContain("Task-Id: test-task-id");
380
+ expect(prompt).toContain("Created with [PostHog Code]");
376
381
  });
377
382
 
378
383
  it("returns default prompt when prUrl is null", () => {
@@ -380,7 +385,7 @@ describe("AgentServer HTTP Mode", () => {
380
385
  const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt(
381
386
  null,
382
387
  );
383
- expect(prompt).toContain("Create a new branch");
388
+ expect(prompt).toContain("posthog-code/");
384
389
  expect(prompt).toContain("Create a draft pull request");
385
390
  expect(prompt).toContain("gh pr create --draft");
386
391
  });
@@ -1062,6 +1062,26 @@ export class AgentServer {
1062
1062
  }
1063
1063
 
1064
1064
  private buildCloudSystemPrompt(prUrl?: string | null): string {
1065
+ const taskId = this.config.taskId;
1066
+ const attributionInstructions = `
1067
+ ## Attribution
1068
+ Do NOT use Claude Code's default attribution (no "Co-Authored-By" trailers, no "Generated with [Claude Code]" lines).
1069
+
1070
+ Instead, add the following trailers to EVERY commit message (after a blank line at the end):
1071
+ Generated-By: PostHog Code
1072
+ Task-Id: ${taskId}
1073
+
1074
+ Example:
1075
+ \`\`\`
1076
+ git commit -m "$(cat <<'EOF'
1077
+ fix: resolve login redirect loop
1078
+
1079
+ Generated-By: PostHog Code
1080
+ Task-Id: ${taskId}
1081
+ EOF
1082
+ )"
1083
+ \`\`\``;
1084
+
1065
1085
  if (prUrl) {
1066
1086
  return `
1067
1087
  # Cloud Task Execution
@@ -1075,8 +1095,7 @@ After completing the requested changes:
1075
1095
 
1076
1096
  Important:
1077
1097
  - Do NOT create a new branch or a new pull request.
1078
- - Do NOT add "Co-Authored-By" trailers to commit messages.
1079
- - Do NOT add "Generated with [Claude Code]" or similar attribution lines to PR descriptions.
1098
+ ${attributionInstructions}
1080
1099
  `;
1081
1100
  }
1082
1101
 
@@ -1105,15 +1124,18 @@ Important:
1105
1124
  # Cloud Task Execution
1106
1125
 
1107
1126
  After completing the requested changes:
1108
- 1. Create a new branch with a descriptive name based on the work done
1127
+ 1. Create a new branch prefixed with \`posthog-code/\` (e.g. \`posthog-code/fix-login-redirect\`) based on the work done
1109
1128
  2. Stage and commit all changes with a clear commit message
1110
1129
  3. Push the branch to origin
1111
- 4. Create a draft pull request using \`gh pr create --draft${this.config.baseBranch ? ` --base ${this.config.baseBranch}` : ""}\` with a descriptive title and body
1130
+ 4. Create a draft pull request using \`gh pr create --draft${this.config.baseBranch ? ` --base ${this.config.baseBranch}` : ""}\` with a descriptive title and body. Add the following footer at the end of the PR description:
1131
+ \`\`\`
1132
+ ---
1133
+ *Created with [PostHog Code](https://posthog.com/code?ref=pr)*
1134
+ \`\`\`
1112
1135
 
1113
1136
  Important:
1114
1137
  - Always create the PR as a draft. Do not ask for confirmation.
1115
- - Do NOT add "Co-Authored-By" trailers to commit messages.
1116
- - Do NOT add "Generated with [Claude Code]" or similar attribution lines to PR descriptions.
1138
+ ${attributionInstructions}
1117
1139
  `;
1118
1140
  }
1119
1141