@myagentroam/agent 0.13.6 → 0.13.8
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/dist/runtime/context/gc-candidates.js +4 -2
- package/dist/runtime/context/gc-runtime.d.ts +2 -2
- package/dist/runtime/context/gc-runtime.js +11 -9
- package/dist/runtime/context/gc.js +1 -1
- package/dist/session/context-gc-protection.d.ts +1 -1
- package/dist/session/context-gc-protection.js +14 -4
- package/package.json +1 -1
|
@@ -126,7 +126,8 @@ export function countSuccessfulNormalRollouts(records, modelId, contextWindowTok
|
|
|
126
126
|
let activeContextWindowTokens = initial.contextWindowTokens;
|
|
127
127
|
let count = 0;
|
|
128
128
|
for (const record of records) {
|
|
129
|
-
if (record.type === 'execution.header'
|
|
129
|
+
if ((record.type === 'execution.header' || record.type === 'compact.completed') &&
|
|
130
|
+
isRecord(record.payload)) {
|
|
130
131
|
activeModelId =
|
|
131
132
|
typeof record.payload.modelId === 'string' ? record.payload.modelId : activeModelId;
|
|
132
133
|
activeContextWindowTokens =
|
|
@@ -153,7 +154,8 @@ function modelConfigurationAt(records, boundarySequence, fallbackModelId, fallba
|
|
|
153
154
|
for (const record of records) {
|
|
154
155
|
if (record.sequence > boundarySequence)
|
|
155
156
|
break;
|
|
156
|
-
if (record.type !== 'execution.header'
|
|
157
|
+
if ((record.type !== 'execution.header' && record.type !== 'compact.completed') ||
|
|
158
|
+
!isRecord(record.payload))
|
|
157
159
|
continue;
|
|
158
160
|
if (typeof record.payload.modelId === 'string')
|
|
159
161
|
modelId = record.payload.modelId;
|
|
@@ -36,8 +36,8 @@ export declare class ContextGcRuntime {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Runs the deterministic planner and commits its checkpoint. Planning and
|
|
39
|
-
* commit failures are opportunistic no-ops
|
|
40
|
-
*
|
|
39
|
+
* commit failures are opportunistic no-ops except under image byte pressure.
|
|
40
|
+
* Ambiguous appends are resolved against the durable checkpoint before adoption.
|
|
41
41
|
*/
|
|
42
42
|
export declare function tryCommitContextGc(input: ContextGcRuntimeInput): Promise<ContextGcCommitResult | false>;
|
|
43
43
|
export {};
|
|
@@ -61,8 +61,8 @@ export class ContextGcRuntime {
|
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Runs the deterministic planner and commits its checkpoint. Planning and
|
|
64
|
-
* commit failures are opportunistic no-ops
|
|
65
|
-
*
|
|
64
|
+
* commit failures are opportunistic no-ops except under image byte pressure.
|
|
65
|
+
* Ambiguous appends are resolved against the durable checkpoint before adoption.
|
|
66
66
|
*/
|
|
67
67
|
export async function tryCommitContextGc(input) {
|
|
68
68
|
return (await attemptContextGc(input)).result;
|
|
@@ -112,7 +112,9 @@ async function attemptContextGc(input) {
|
|
|
112
112
|
return deferred;
|
|
113
113
|
draft = plan.draft;
|
|
114
114
|
}
|
|
115
|
-
catch {
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (mediaRequired)
|
|
117
|
+
throw error;
|
|
116
118
|
return deferred;
|
|
117
119
|
}
|
|
118
120
|
try {
|
|
@@ -124,15 +126,15 @@ async function attemptContextGc(input) {
|
|
|
124
126
|
}
|
|
125
127
|
catch (commitError) {
|
|
126
128
|
try {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
129
|
+
const result = await matchingCheckpointWasPersisted(input.store, input.sessionId, draft, records);
|
|
130
|
+
if (result)
|
|
131
|
+
return { ...deferred, result };
|
|
131
132
|
}
|
|
132
133
|
catch {
|
|
133
|
-
//
|
|
134
|
+
// Preserve the original failure when the append outcome cannot be confirmed.
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
+
if (mediaRequired)
|
|
137
|
+
throw commitError;
|
|
136
138
|
return deferred;
|
|
137
139
|
}
|
|
138
140
|
}
|
|
@@ -209,7 +209,7 @@ function latestUsageRecord(records, selectedModelId) {
|
|
|
209
209
|
let activeModelId = selectedModelId;
|
|
210
210
|
let latest;
|
|
211
211
|
for (const record of records) {
|
|
212
|
-
if (record.type === 'execution.header') {
|
|
212
|
+
if (record.type === 'execution.header' || record.type === 'compact.completed') {
|
|
213
213
|
const modelId = modelIdFromRecord(record);
|
|
214
214
|
if (modelId)
|
|
215
215
|
activeModelId = modelId;
|
|
@@ -4,7 +4,7 @@ export declare function contextGcProtectionMature(count: {
|
|
|
4
4
|
readonly rollouts: number;
|
|
5
5
|
readonly thinking: number;
|
|
6
6
|
}): boolean;
|
|
7
|
-
/** One immutable boundary index
|
|
7
|
+
/** One immutable boundary index; Compact seeds configuration when its execution header is sliced out. */
|
|
8
8
|
export declare function buildContextGcProtection(records: readonly SessionRecord[], modelId: string, contextWindowTokens: number): {
|
|
9
9
|
after(anchor: number): {
|
|
10
10
|
rollouts: number;
|
|
@@ -3,13 +3,23 @@ export const CONTEXT_GC_TEXT_PROTECTION_ROLLOUTS = 10;
|
|
|
3
3
|
export function contextGcProtectionMature(count) {
|
|
4
4
|
return count.rollouts >= CONTEXT_GC_TEXT_PROTECTION_ROLLOUTS && count.thinking >= 3;
|
|
5
5
|
}
|
|
6
|
-
/** One immutable boundary index
|
|
6
|
+
/** One immutable boundary index; Compact seeds configuration when its execution header is sliced out. */
|
|
7
7
|
export function buildContextGcProtection(records, modelId, contextWindowTokens) {
|
|
8
8
|
const configurations = new Map();
|
|
9
9
|
const attempts = new Map();
|
|
10
10
|
const successful = [];
|
|
11
11
|
const thinking = [];
|
|
12
|
+
let baseline = { modelId, window: contextWindowTokens };
|
|
12
13
|
for (const record of records) {
|
|
14
|
+
if (record.type === 'compact.completed' && isRecord(record.payload)) {
|
|
15
|
+
baseline = {
|
|
16
|
+
modelId: typeof record.payload.modelId === 'string' ? record.payload.modelId : baseline.modelId,
|
|
17
|
+
window: typeof record.payload.contextWindowTokens === 'number'
|
|
18
|
+
? record.payload.contextWindowTokens
|
|
19
|
+
: baseline.window
|
|
20
|
+
};
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
13
23
|
if (!record.executionId ||
|
|
14
24
|
!['execution.header', 'model.attempt', 'model.context'].includes(record.type) ||
|
|
15
25
|
!isRecord(record.payload))
|
|
@@ -28,12 +38,12 @@ export function buildContextGcProtection(records, modelId, contextWindowTokens)
|
|
|
28
38
|
if (payload.purpose !== 'EXECUTION')
|
|
29
39
|
continue;
|
|
30
40
|
if (payload.state === 'STARTED') {
|
|
31
|
-
const configuration = configurations.get(key);
|
|
41
|
+
const configuration = configurations.get(key) ?? baseline;
|
|
32
42
|
attempts.set(key, {
|
|
33
43
|
start: record.sequence,
|
|
34
44
|
matching: payload.purpose === 'EXECUTION' &&
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
configuration.modelId === modelId &&
|
|
46
|
+
configuration.window === contextWindowTokens,
|
|
37
47
|
native: new Set()
|
|
38
48
|
});
|
|
39
49
|
}
|