@triflux/remote 10.63.0 → 10.64.0
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/hub/team/session-context.mjs +29 -11
- package/package.json +1 -1
|
@@ -23,14 +23,21 @@ const MODEL_CONTEXT = [
|
|
|
23
23
|
},
|
|
24
24
|
];
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const CONTEXT_THRESHOLDS = {
|
|
27
27
|
claude: { warnContextPct: 60, maxContextPct: 90 },
|
|
28
|
-
codex: { warnContextPct:
|
|
28
|
+
codex: { warnContextPct: 60, maxContextPct: 85 },
|
|
29
29
|
};
|
|
30
|
+
// rollout 실행 창을 못 읽으면 1.05M 표 값이 분모라 실제 창보다 비율이 작게 나온다.
|
|
31
|
+
const CODEX_MODEL_WINDOW_THRESHOLDS = { warnContextPct: 15, maxContextPct: 22 };
|
|
30
32
|
|
|
31
33
|
const rolloutCache = new Map();
|
|
32
34
|
|
|
33
|
-
export function modelContext(
|
|
35
|
+
export function modelContext(
|
|
36
|
+
cli,
|
|
37
|
+
model,
|
|
38
|
+
estimatedContextTokens = null,
|
|
39
|
+
rolloutContextWindow = null,
|
|
40
|
+
) {
|
|
34
41
|
const entry = MODEL_CONTEXT.find(
|
|
35
42
|
(item) => item.cli === cli && item.model.test(model || ""),
|
|
36
43
|
);
|
|
@@ -38,18 +45,20 @@ export function modelContext(cli, model, estimatedContextTokens = null) {
|
|
|
38
45
|
const executionContextLimitTokens =
|
|
39
46
|
cli === "claude" && process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT === "1"
|
|
40
47
|
? 200_000
|
|
41
|
-
:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
: rolloutContextWindow;
|
|
49
|
+
// Codex 는 rollout 이 보고한 창이 실제 실행 한도라 표 값과 무관하게 그 창을 쓴다.
|
|
50
|
+
const effectiveLimit =
|
|
51
|
+
cli === "codex"
|
|
52
|
+
? (executionContextLimitTokens ?? contextLimitTokens)
|
|
53
|
+
: contextLimitTokens &&
|
|
54
|
+
Math.min(contextLimitTokens, executionContextLimitTokens ?? Infinity);
|
|
46
55
|
return {
|
|
47
56
|
estimatedContextTokens,
|
|
48
57
|
contextLimitTokens,
|
|
49
58
|
contextLimitSource: entry?.source ?? null,
|
|
50
59
|
...(executionContextLimitTokens ? { executionContextLimitTokens } : {}),
|
|
51
60
|
contextPct:
|
|
52
|
-
|
|
61
|
+
effectiveLimit && Number.isFinite(estimatedContextTokens)
|
|
53
62
|
? (estimatedContextTokens / effectiveLimit) * 100
|
|
54
63
|
: null,
|
|
55
64
|
};
|
|
@@ -60,7 +69,10 @@ export function contextGuard(
|
|
|
60
69
|
context,
|
|
61
70
|
{ warnContextPct, maxContextPct } = {},
|
|
62
71
|
) {
|
|
63
|
-
const defaults =
|
|
72
|
+
const defaults =
|
|
73
|
+
cli === "codex" && !context?.executionContextLimitTokens
|
|
74
|
+
? CODEX_MODEL_WINDOW_THRESHOLDS
|
|
75
|
+
: CONTEXT_THRESHOLDS[cli];
|
|
64
76
|
const warn = warnContextPct ?? defaults?.warnContextPct ?? 0;
|
|
65
77
|
const max = maxContextPct ?? defaults?.maxContextPct ?? 0;
|
|
66
78
|
const fields = {
|
|
@@ -90,6 +102,7 @@ export function contextGuard(
|
|
|
90
102
|
inputSent: false,
|
|
91
103
|
hint: "세션을 승계한 뒤 새 세션에 요청하라.",
|
|
92
104
|
...fields,
|
|
105
|
+
thresholdPct: max,
|
|
93
106
|
};
|
|
94
107
|
}
|
|
95
108
|
return warn > 0 && fields.contextPct >= warn
|
|
@@ -206,7 +219,12 @@ export async function readCodexContext(rolloutPath, threadId) {
|
|
|
206
219
|
state.mtimeMs = stat.mtimeMs;
|
|
207
220
|
rolloutCache.set(rolloutPath, state);
|
|
208
221
|
return {
|
|
209
|
-
...modelContext(
|
|
222
|
+
...modelContext(
|
|
223
|
+
"codex",
|
|
224
|
+
state.model,
|
|
225
|
+
state.tokens,
|
|
226
|
+
state.executionContextLimitTokens,
|
|
227
|
+
),
|
|
210
228
|
model: state.model,
|
|
211
229
|
compactCount: state.compactCount,
|
|
212
230
|
compact: state.compact,
|