Skip to content

Commit 9e310fa

Browse files
committed
Reset context usage to zero on compaction
1 parent 20b1ebb commit 9e310fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/agent/src/adapters/claude/claude-agent.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,18 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
371371
switch (message.type) {
372372
case "system":
373373
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.
374376
lastAssistantTotalUsage = 0;
375377
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+
});
376386
}
377387
if (message.subtype === "local_command_output") {
378388
promptReplayed = true;

0 commit comments

Comments
 (0)