@tangle-network/agent-app 0.60.274 → 0.60.276
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.
|
@@ -1239,6 +1239,7 @@ function createRouterTurnProducer(options) {
|
|
|
1239
1239
|
let wake = null;
|
|
1240
1240
|
let done = false;
|
|
1241
1241
|
let outcome = null;
|
|
1242
|
+
let usageReported = false;
|
|
1242
1243
|
const parts = [];
|
|
1243
1244
|
const toolParts = /* @__PURE__ */ new Map();
|
|
1244
1245
|
let textPart = null;
|
|
@@ -1300,6 +1301,7 @@ function createRouterTurnProducer(options) {
|
|
|
1300
1301
|
reasoningPart = null;
|
|
1301
1302
|
reasoningClock.settle();
|
|
1302
1303
|
} else if (event.type === "usage") {
|
|
1304
|
+
usageReported = true;
|
|
1303
1305
|
push({ type: "usage", usage: {
|
|
1304
1306
|
promptTokens: event.promptTokens,
|
|
1305
1307
|
completionTokens: event.completionTokens,
|
|
@@ -1343,13 +1345,13 @@ function createRouterTurnProducer(options) {
|
|
|
1343
1345
|
await run;
|
|
1344
1346
|
}
|
|
1345
1347
|
const snapshot = () => parts.map((part) => part.type === "reasoning" ? { ...part, time: reasoningClock.time(part) } : { ...part });
|
|
1346
|
-
const usage = () =>
|
|
1348
|
+
const usage = () => !outcome || !usageReported ? {} : {
|
|
1347
1349
|
// The Router's prompt tokens include the cached ones; the sandbox lanes report input and cache reads apart, so
|
|
1348
1350
|
// the stored row counts them apart here too and `inputTokens + cacheReadTokens` is the prompt on either lane.
|
|
1349
|
-
inputTokens:
|
|
1350
|
-
outputTokens: outcome
|
|
1351
|
-
...outcome
|
|
1352
|
-
}
|
|
1351
|
+
inputTokens: outcome.usage.promptTokens - (outcome.usage.cachedPromptTokens ?? 0),
|
|
1352
|
+
outputTokens: outcome.usage.completionTokens,
|
|
1353
|
+
...outcome.usage.cachedPromptTokens !== void 0 ? { cacheReadTokens: outcome.usage.cachedPromptTokens } : {}
|
|
1354
|
+
};
|
|
1353
1355
|
return {
|
|
1354
1356
|
stream: stream(),
|
|
1355
1357
|
finalText: () => outcome?.text ?? "",
|