@posthog/agent 2.3.11 → 2.3.13

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.11",
3
+ "version": "2.3.13",
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": {
@@ -73,6 +73,7 @@ import {
73
73
  } from "./tools.js";
74
74
  import type {
75
75
  BackgroundTerminal,
76
+ EffortLevel,
76
77
  NewSessionMeta,
77
78
  Session,
78
79
  ToolUseCache,
@@ -558,6 +559,10 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
558
559
  const sdkModelId = toSdkModelId(params.value);
559
560
  await this.session.query.setModel(sdkModelId);
560
561
  this.session.modelId = params.value;
562
+ } else if (params.configId === "effort") {
563
+ const newEffort = params.value as EffortLevel;
564
+ this.session.effort = newEffort;
565
+ this.session.queryOptions.effort = newEffort;
561
566
  }
562
567
 
563
568
  this.session.configOptions = this.session.configOptions.map((o) =>
@@ -623,6 +628,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
623
628
 
624
629
  const meta = params._meta as NewSessionMeta | undefined;
625
630
  const taskId = meta?.persistence?.taskId;
631
+ const effort = meta?.claudeCode?.options?.effort as EffortLevel | undefined;
626
632
 
627
633
  // We want to create a new session id unless it is resume,
628
634
  // but not resume + forkSession.
@@ -673,6 +679,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
673
679
  onModeChange: this.createOnModeChange(),
674
680
  onProcessSpawned: this.options?.onProcessSpawned,
675
681
  onProcessExited: this.options?.onProcessExited,
682
+ effort,
676
683
  });
677
684
 
678
685
  // Use the same abort controller that buildSessionOptions gave to the query
@@ -682,6 +689,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
682
689
 
683
690
  const session: Session = {
684
691
  query: q,
692
+ queryOptions: options,
685
693
  input,
686
694
  cancelled: false,
687
695
  settingsManager,
@@ -693,6 +701,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
693
701
  cachedReadTokens: 0,
694
702
  cachedWriteTokens: 0,
695
703
  },
704
+ effort,
696
705
  configOptions: [],
697
706
  promptRunning: false,
698
707
  pendingMessages: new Map(),
@@ -790,7 +799,11 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
790
799
  ),
791
800
  };
792
801
 
793
- const configOptions = this.buildConfigOptions(permissionMode, modelOptions);
802
+ const configOptions = this.buildConfigOptions(
803
+ permissionMode,
804
+ modelOptions,
805
+ effort ?? "high",
806
+ );
794
807
  session.configOptions = configOptions;
795
808
 
796
809
  if (!creationOpts.skipBackgroundFetches) {
@@ -844,6 +857,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
844
857
  currentModelId: string;
845
858
  options: SessionConfigSelectOption[];
846
859
  },
860
+ currentEffort: EffortLevel = "high",
847
861
  ): SessionConfigOption[] {
848
862
  const modeOptions = getAvailableModes().map((mode) => ({
849
863
  value: mode.id,
@@ -871,6 +885,20 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
871
885
  category: "model" as SessionConfigOptionCategory,
872
886
  description: "Choose which model Claude should use",
873
887
  },
888
+ {
889
+ id: "effort",
890
+ name: "Effort",
891
+ type: "select",
892
+ currentValue: currentEffort,
893
+ options: [
894
+ { value: "low", name: "Low" },
895
+ { value: "medium", name: "Medium" },
896
+ { value: "high", name: "High" },
897
+ { value: "max", name: "Max" },
898
+ ],
899
+ category: "thought_level" as SessionConfigOptionCategory,
900
+ description: "Controls how much effort Claude puts into its response",
901
+ },
874
902
  ];
875
903
  }
876
904
 
@@ -17,6 +17,7 @@ import {
17
17
  type OnModeChange,
18
18
  } from "../hooks.js";
19
19
  import type { CodeExecutionMode } from "../tools.js";
20
+ import type { EffortLevel } from "../types.js";
20
21
  import { DEFAULT_MODEL } from "./models.js";
21
22
  import type { SettingsManager } from "./settings.js";
22
23
 
@@ -43,6 +44,7 @@ export interface BuildOptionsParams {
43
44
  onModeChange?: OnModeChange;
44
45
  onProcessSpawned?: (info: ProcessSpawnedInfo) => void;
45
46
  onProcessExited?: (pid: number) => void;
47
+ effort?: EffortLevel;
46
48
  }
47
49
 
48
50
  const BRANCH_NAMING_INSTRUCTIONS = `
@@ -295,6 +297,10 @@ export function buildSessionOptions(params: BuildOptionsParams): Options {
295
297
  options.additionalDirectories = params.additionalDirectories;
296
298
  }
297
299
 
300
+ if (params.effort) {
301
+ options.effort = params.effort;
302
+ }
303
+
298
304
  clearStatsigCache();
299
305
  return options;
300
306
  }
@@ -13,6 +13,8 @@ import type { BaseSession } from "../base-acp-agent.js";
13
13
  import type { SettingsManager } from "./session/settings.js";
14
14
  import type { CodeExecutionMode } from "./tools.js";
15
15
 
16
+ export type EffortLevel = "low" | "medium" | "high" | "max";
17
+
16
18
  export type AccumulatedUsage = {
17
19
  inputTokens: number;
18
20
  outputTokens: number;
@@ -38,6 +40,8 @@ export type PendingMessage = {
38
40
 
39
41
  export type Session = BaseSession & {
40
42
  query: Query;
43
+ /** The Options object passed to query() — mutating it affects subsequent prompts */
44
+ queryOptions: Options;
41
45
  input: Pushable<SDKUserMessage>;
42
46
  settingsManager: SettingsManager;
43
47
  permissionMode: CodeExecutionMode;
@@ -46,6 +50,7 @@ export type Session = BaseSession & {
46
50
  taskRunId?: string;
47
51
  lastPlanFilePath?: string;
48
52
  lastPlanContent?: string;
53
+ effort?: EffortLevel;
49
54
  configOptions: SessionConfigOption[];
50
55
  accumulatedUsage: AccumulatedUsage;
51
56
  promptRunning: boolean;