@cocorograph/hub-agent 0.7.61 → 0.7.62
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/package.json +1 -1
- package/src/usage.mjs +14 -7
package/package.json
CHANGED
package/src/usage.mjs
CHANGED
|
@@ -1445,15 +1445,22 @@ export async function codexUsageForThread(threadId) {
|
|
|
1445
1445
|
const rateLimits = found.payload.rate_limits
|
|
1446
1446
|
|
|
1447
1447
|
let contextPercent = null
|
|
1448
|
-
const totalTok = info?.total_token_usage
|
|
1449
1448
|
const windowSize = info?.model_context_window
|
|
1450
|
-
|
|
1449
|
+
// context 窓の「現在の占有率」は last_token_usage(直近ターンで実際に窓へ載った
|
|
1450
|
+
// トークン)で測る。total_token_usage は会話累積(キャッシュ再利用分も加算し
|
|
1451
|
+
// 単調増加)なので、ターンを重ねると窓サイズを超過し Math.min(100,…) で 100% に
|
|
1452
|
+
// クランプされてドーナツが固着する(2026-07-15 バグ修正: 実測で累積 1,341,719 /
|
|
1453
|
+
// 窓 258,400 = 519% → 100% 張り付き。実占有は last=66,973 → 25.9%)。Codex は
|
|
1454
|
+
// 自動コンパクションで実文脈を使い回すため、累積で割ると必ず張り付く。
|
|
1455
|
+
// last_token_usage が無い旧 Codex 版のみ従来の total_token_usage にフォールバック。
|
|
1456
|
+
const usageForContext = info?.last_token_usage ?? info?.total_token_usage
|
|
1457
|
+
if (usageForContext && typeof windowSize === "number" && windowSize > 0) {
|
|
1451
1458
|
const tokens =
|
|
1452
|
-
typeof
|
|
1453
|
-
?
|
|
1454
|
-
: (
|
|
1455
|
-
(
|
|
1456
|
-
(
|
|
1459
|
+
typeof usageForContext.total_tokens === "number"
|
|
1460
|
+
? usageForContext.total_tokens
|
|
1461
|
+
: (usageForContext.input_tokens || 0) +
|
|
1462
|
+
(usageForContext.cached_input_tokens || 0) +
|
|
1463
|
+
(usageForContext.output_tokens || 0)
|
|
1457
1464
|
contextPercent = Math.min(100, Math.round((tokens / windowSize) * 1000) / 10)
|
|
1458
1465
|
}
|
|
1459
1466
|
|