@posthog/agent 2.3.207 → 2.3.209

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.207",
3
+ "version": "2.3.209",
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": {
@@ -371,8 +371,18 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
371
371
  switch (message.type) {
372
372
  case "system":
373
373
  if (message.subtype === "compact_boundary") {
374
+ // Send used:0 immediately so the client doesn't keep showing
375
+ // the stale pre-compaction context size until the next turn.
374
376
  lastAssistantTotalUsage = 0;
375
377
  promptReplayed = true;
378
+ await this.client.sessionUpdate({
379
+ sessionId: params.sessionId,
380
+ update: {
381
+ sessionUpdate: "usage_update",
382
+ used: 0,
383
+ size: lastContextWindowSize,
384
+ },
385
+ });
376
386
  }
377
387
  if (message.subtype === "local_command_output") {
378
388
  promptReplayed = true;
@@ -530,6 +540,11 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
530
540
  }
531
541
 
532
542
  // Store latest assistant usage (excluding subagents)
543
+ // Sum all token types as a proxy for post-turn context occupancy:
544
+ // current turn's output will become next turn's input.
545
+ // Note: per the Anthropic API, input_tokens excludes cache tokens —
546
+ // cache_read and cache_creation are reported separately, so summing
547
+ // all four fields is not double-counting.
533
548
  if (
534
549
  "usage" in message.message &&
535
550
  message.parent_tool_use_id === null
@@ -544,6 +559,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
544
559
  };
545
560
  lastAssistantTotalUsage =
546
561
  usage.input_tokens +
562
+ usage.output_tokens +
547
563
  usage.cache_read_input_tokens +
548
564
  usage.cache_creation_input_tokens;
549
565