@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/dist/agent.js +10 -2
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +10 -2
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +10 -2
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/claude/claude-agent.ts +16 -0
package/package.json
CHANGED
|
@@ -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
|
|