Skip to content

Commit b1bd064

Browse files
maria-rcksotavio
andauthored
fix(acp): keep turn spending out of context usage (#27927)
Co-authored-by: Otavio Salvador <[email protected]>
1 parent 9f9eaff commit b1bd064

4 files changed

Lines changed: 3 additions & 20 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,6 @@ describe("AcpRegistryAdapterV2", () => {
14771477
[
14781478
{ usedTokens: 2_500, maxTokens: 10_000, cost: { amount: 0.42, currency: "USD" } },
14791479
{ usedTokens: 2_500, maxTokens: 10_000, cost: { amount: 0.42, currency: "USD" } },
1480-
{ usedTokens: 3_000 },
14811480
],
14821481
);
14831482
assert.deepEqual(childThreads.at(-1)?.nativeMetadata, {

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4616,10 +4616,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
46164616
if (yield* projectAgentTerminalUpdate(notification, context)) return;
46174617
if (
46184618
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"
46234620
) {
46244621
const stateEvent = parseSessionUpdateEvent(notification).events.find(
46254622
(event) => event._tag === "UsageUpdated" || event._tag === "SessionInfoUpdated",
@@ -4670,7 +4667,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
46704667
providerThread,
46714668
});
46724669
}
4673-
if (update.sessionUpdate !== "state_update") return;
4670+
return;
46744671
}
46754672
if (yield* followNativeChild(notification, context)) return;
46764673
if (

‎packages/provider-acp/src/server/runtimeModel.test.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,10 +1047,7 @@ describe("AcpRuntimeModel", () => {
10471047
data: { rawOutput: "Retained the implementation decisions." },
10481048
},
10491049
});
1050-
expect(idle.events[0]).toMatchObject({
1051-
_tag: "UsageUpdated",
1052-
usage: { usedTokens: 420 },
1053-
});
1050+
expect(idle.events).toEqual([]);
10541051
});
10551052

10561053
it("applies ACP v2 agent-owned terminal snapshots and output chunks", () => {

‎packages/provider-acp/src/server/runtimeModel.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,16 +1549,6 @@ export function parseSessionUpdateEvent(params: EffectAcpSchema.SessionNotificat
15491549
}
15501550
break;
15511551
}
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-
}
15621552
case "usage_update": {
15631553
const currency = upd.cost?.currency.trim().slice(0, 32);
15641554
events.push({

0 commit comments

Comments
 (0)