The best way to control Claude Code, Codex and more from any computer or phone
fix(acp): keep turn spending out of context usage (#27927)
Co-authored-by: Otavio Salvador <25278+otavio@users.noreply.github.com>
maria committed
Nov 1, 2026 at 02:19 UTC
b1bd06432db9c9cb795a3b4bba20370e8b6166c2
4 files changed
+3
-20
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
-1
@@ -1477,7 +1477,6 @@ describe("AcpRegistryAdapterV2", () => {
1477
[
1478
{ usedTokens: 2_500, maxTokens: 10_000, cost: { amount: 0.42, currency: "USD" } },
1479
{ usedTokens: 2_500, maxTokens: 10_000, cost: { amount: 0.42, currency: "USD" } },
1480
- { usedTokens: 3_000 },
1480
],
1481
);
1482
assert.deepEqual(childThreads.at(-1)?.nativeMetadata, {
packages/provider-acp/src/server/adapter.ts
+2
-5
@@ -4616,10 +4616,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
4616
if (yield* projectAgentTerminalUpdate(notification, context)) return;
4617
if (
4618
update.sessionUpdate === "usage_update" ||
4619
- update.sessionUpdate === "session_info_update" ||
4620
- (update.sessionUpdate === "state_update" &&
4621
- update.state === "idle" &&
4622
- update.usage != null)
4619
+ update.sessionUpdate === "session_info_update"
4620
) {
4621
const stateEvent = parseSessionUpdateEvent(notification).events.find(
4622
(event) => event._tag === "UsageUpdated" || event._tag === "SessionInfoUpdated",
@@ -4670,7 +4667,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
4667
providerThread,
4668
});
4669
}
4673
- if (update.sessionUpdate !== "state_update") return;
4670
+ return;
4671
}
4672
if (yield* followNativeChild(notification, context)) return;
4673
if (
packages/provider-acp/src/server/runtimeModel.test.ts
+1
-4
@@ -1047,10 +1047,7 @@ describe("AcpRuntimeModel", () => {
1047
data: { rawOutput: "Retained the implementation decisions." },
1048
},
1049
});
1050
- expect(idle.events[0]).toMatchObject({
1051
- _tag: "UsageUpdated",
1052
- usage: { usedTokens: 420 },
1053
- });
1050
+ expect(idle.events).toEqual([]);
1051
});
1052
1053
it("applies ACP v2 agent-owned terminal snapshots and output chunks", () => {
packages/provider-acp/src/server/runtimeModel.ts
-10
@@ -1549,16 +1549,6 @@ export function parseSessionUpdateEvent(params: EffectAcpSchema.SessionNotificat
1549
}
1550
break;
1551
}
1552
- case "state_update": {
1553
- if (upd.state === "idle" && upd.usage !== undefined && upd.usage !== null) {
1554
- events.push({
1555
- _tag: "UsageUpdated",
1556
- usage: { usedTokens: upd.usage.totalTokens },
1557
- rawPayload: params,
1558
- });
1559
- }
1560
- break;
1561
- }
1552
case "usage_update": {
1553
const currency = upd.cost?.currency.trim().slice(0, 32);
1554
events.push({