@myagentroam/agent 0.15.0 → 0.15.2
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/cli/catalog-file.d.ts +0 -2
- package/dist/cli/main.js +1 -8
- package/dist/model/configuration.d.ts +0 -5
- package/dist/model/configuration.js +0 -4
- package/dist/runtime/context/gc.js +1 -0
- package/dist/sdk/execution-context-coordinator.d.ts +1 -1
- package/dist/sdk/execution-context-coordinator.js +9 -10
- package/dist/sdk/execution-tool-catalog.js +1 -2
- package/dist/sdk/session-execution-factory.js +1 -2
- package/dist/session/context-gc-checkpoint.js +2 -0
- package/package.json +1 -1
|
@@ -32,7 +32,6 @@ export declare function serializeModel(model: CliModelConfiguration): {
|
|
|
32
32
|
titleGeneration: boolean;
|
|
33
33
|
codeMode: boolean;
|
|
34
34
|
contextGcMode?: "off" | "auto" | "with_thought" | undefined;
|
|
35
|
-
gcEnabled?: boolean | undefined;
|
|
36
35
|
smartCompactEnabled?: boolean | undefined;
|
|
37
36
|
fastMode?: boolean | undefined;
|
|
38
37
|
serviceTier?: "default" | "priority" | "auto" | "flex" | "fast" | "ultrafast" | undefined;
|
|
@@ -70,7 +69,6 @@ export declare function serializeModel(model: CliModelConfiguration): {
|
|
|
70
69
|
titleGeneration: boolean;
|
|
71
70
|
codeMode: boolean;
|
|
72
71
|
contextGcMode?: "off" | "auto" | "with_thought" | undefined;
|
|
73
|
-
gcEnabled?: boolean | undefined;
|
|
74
72
|
smartCompactEnabled?: boolean | undefined;
|
|
75
73
|
fastMode?: boolean | undefined;
|
|
76
74
|
serviceTier?: "default" | "priority" | "auto" | "flex" | "fast" | "ultrafast" | undefined;
|
package/dist/cli/main.js
CHANGED
|
@@ -149,14 +149,7 @@ async function modelsCommand(home, arguments_, codexAuthFile) {
|
|
|
149
149
|
const defaultReasoningEffortOption = option('--default-reasoning-effort');
|
|
150
150
|
const model = {
|
|
151
151
|
useResourceUrl: existing?.useResourceUrl ?? false,
|
|
152
|
-
|
|
153
|
-
? { contextGcMode: 'off' }
|
|
154
|
-
: {
|
|
155
|
-
...(existing.contextGcMode === undefined
|
|
156
|
-
? {}
|
|
157
|
-
: { contextGcMode: existing.contextGcMode }),
|
|
158
|
-
gcEnabled: existing.gcEnabled ?? true
|
|
159
|
-
}),
|
|
152
|
+
contextGcMode: existing?.contextGcMode ?? 'off',
|
|
160
153
|
id,
|
|
161
154
|
name: required(option('--name', existing?.name), '--name'),
|
|
162
155
|
protocol,
|
|
@@ -23,10 +23,6 @@ declare const contextGcModeSchema: z.ZodEnum<{
|
|
|
23
23
|
with_thought: "with_thought";
|
|
24
24
|
}>;
|
|
25
25
|
export type ContextGcMode = z.infer<typeof contextGcModeSchema>;
|
|
26
|
-
export declare function resolveContextGcMode(model: {
|
|
27
|
-
contextGcMode?: ContextGcMode | undefined;
|
|
28
|
-
gcEnabled?: boolean | undefined;
|
|
29
|
-
}): ContextGcMode;
|
|
30
26
|
declare const rawModelSchema: z.ZodObject<{
|
|
31
27
|
id: z.ZodString;
|
|
32
28
|
name: z.ZodString;
|
|
@@ -72,7 +68,6 @@ declare const rawModelSchema: z.ZodObject<{
|
|
|
72
68
|
auto: "auto";
|
|
73
69
|
with_thought: "with_thought";
|
|
74
70
|
}>>;
|
|
75
|
-
gcEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
76
71
|
smartCompactEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
77
72
|
useResourceUrl: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
78
73
|
fastMode: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -16,9 +16,6 @@ export const agentReasoningEffortSchema = z.enum([
|
|
|
16
16
|
'ultra'
|
|
17
17
|
]);
|
|
18
18
|
const contextGcModeSchema = z.enum(['off', 'auto', 'with_thought']);
|
|
19
|
-
export function resolveContextGcMode(model) {
|
|
20
|
-
return model.contextGcMode ?? (model.gcEnabled === false ? 'off' : 'auto');
|
|
21
|
-
}
|
|
22
19
|
const modelFieldsSchema = z
|
|
23
20
|
.object({
|
|
24
21
|
id: z
|
|
@@ -45,7 +42,6 @@ const modelFieldsSchema = z
|
|
|
45
42
|
titleGeneration: z.boolean().optional().default(false),
|
|
46
43
|
codeMode: z.boolean().optional().default(false),
|
|
47
44
|
contextGcMode: contextGcModeSchema.optional(),
|
|
48
|
-
gcEnabled: z.boolean().optional(),
|
|
49
45
|
smartCompactEnabled: z.boolean().optional(),
|
|
50
46
|
useResourceUrl: z.boolean().optional().default(false),
|
|
51
47
|
fastMode: z.boolean().optional(),
|
|
@@ -217,6 +217,7 @@ function latestUsageRecord(records, selectedModelId) {
|
|
|
217
217
|
else if (activeModelId === selectedModelId &&
|
|
218
218
|
isRecord(record.payload) &&
|
|
219
219
|
record.payload.type === 'usage.updated' &&
|
|
220
|
+
record.payload.purpose !== 'compact' &&
|
|
220
221
|
modelContextUsage(record.payload) !== undefined)
|
|
221
222
|
latest = record;
|
|
222
223
|
}
|
|
@@ -56,7 +56,7 @@ export declare class ExecutionContextCoordinator {
|
|
|
56
56
|
ensureBudget(): Promise<void>;
|
|
57
57
|
checkpoint(round: PreparedExecutionRound<RoundToolScope>, usage: GcUsage, thoughtCallIds?: readonly string[]): Promise<void>;
|
|
58
58
|
/** Merge a one-round Thought trigger with the existing dispatch-time hard limit. */
|
|
59
|
-
prepareRequestGc(round: GcRound, messages: readonly SessionModelMessage[],
|
|
59
|
+
prepareRequestGc(round: GcRound, messages: readonly SessionModelMessage[], latestUsage: GcUsage, media: ContextGcRuntimeInput['inlineMedia']): Promise<boolean>;
|
|
60
60
|
gc(round: GcRound, usage: GcUsage, media: ContextGcRuntimeInput['inlineMedia'], includeProcesses?: boolean): Promise<boolean>;
|
|
61
61
|
}
|
|
62
62
|
export {};
|
|
@@ -5,7 +5,7 @@ import { THOUGHT_TOOL_NAME } from '../tools/agent/thought.js';
|
|
|
5
5
|
export class ExecutionContextCoordinator {
|
|
6
6
|
ports;
|
|
7
7
|
#boundary;
|
|
8
|
-
#
|
|
8
|
+
#thoughtCallIds = [];
|
|
9
9
|
constructor(ports) {
|
|
10
10
|
this.ports = ports;
|
|
11
11
|
this.#boundary = ports.initialBoundary;
|
|
@@ -85,25 +85,24 @@ export class ExecutionContextCoordinator {
|
|
|
85
85
|
if (this.ports.contextGcMode === 'auto' && !this.ports.compact.pending)
|
|
86
86
|
await this.gc(round, usage, await this.ports.resources.gcCandidate(), true);
|
|
87
87
|
if (this.ports.contextGcMode === 'with_thought') {
|
|
88
|
-
this.#
|
|
89
|
-
if (
|
|
88
|
+
this.#thoughtCallIds = thoughtCallIds;
|
|
89
|
+
if (thoughtCallIds.length === 0 && !this.ports.compact.pending)
|
|
90
90
|
this.ports.gc.skipRollout(usage, this.ports.window);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
/** Merge a one-round Thought trigger with the existing dispatch-time hard limit. */
|
|
94
|
-
async prepareRequestGc(round, messages,
|
|
95
|
-
const pending = this.#
|
|
96
|
-
this.#
|
|
97
|
-
const thought = pending
|
|
94
|
+
async prepareRequestGc(round, messages, latestUsage, media) {
|
|
95
|
+
const pending = this.#thoughtCallIds;
|
|
96
|
+
this.#thoughtCallIds = [];
|
|
97
|
+
const thought = pending.length > 0 &&
|
|
98
98
|
messages.some((message) => message.role === 'tool_call' &&
|
|
99
99
|
message.name === THOUGHT_TOOL_NAME &&
|
|
100
100
|
message.callId !== undefined &&
|
|
101
|
-
pending.
|
|
101
|
+
pending.includes(message.callId));
|
|
102
102
|
const hardLimit = media?.reason === 'HARD_LIMIT';
|
|
103
103
|
if (!thought && !hardLimit)
|
|
104
104
|
return false;
|
|
105
|
-
|
|
106
|
-
return this.gc(round, hardLimit ? usage : pending?.usage, media, thought);
|
|
105
|
+
return this.gc(round, latestUsage, media, thought);
|
|
107
106
|
}
|
|
108
107
|
async gc(round, usage, media, includeProcesses = false) {
|
|
109
108
|
if (this.ports.contextGcMode === 'off' || this.ports.compact.pending)
|
|
@@ -7,7 +7,6 @@ import { discoveredMcpToolNames, rebindMcpToolSearchOutputs } from '../tools/mcp
|
|
|
7
7
|
import { BUILTIN_TOOL_DEFINITIONS } from '../tools/registry.js';
|
|
8
8
|
import { toolCallers } from '../tools/callers.js';
|
|
9
9
|
import { ExecutionToolSources } from './extension-tools.js';
|
|
10
|
-
import { resolveContextGcMode } from '../model/configuration.js';
|
|
11
10
|
import { THOUGHT_TOOL_NAME } from '../tools/agent/thought.js';
|
|
12
11
|
/** Initializes one Execution's catalog before Extension attachment owns its bindings. */
|
|
13
12
|
export async function initializeExecutionToolCatalog(input) {
|
|
@@ -62,7 +61,7 @@ export class ExecutionToolCatalog {
|
|
|
62
61
|
if (this.input.child && (tool.agentScope === 'ROOT_ONLY' || tool.name === 'question'))
|
|
63
62
|
return false;
|
|
64
63
|
if (tool.name === THOUGHT_TOOL_NAME)
|
|
65
|
-
return
|
|
64
|
+
return this.input.mode !== 'compact' && this.input.model.contextGcMode === 'with_thought';
|
|
66
65
|
if (tool.name === 'tool_search')
|
|
67
66
|
return this.input.registry.hasDeferred;
|
|
68
67
|
return tool.name === 'code_exec' || tool.name === 'code_exec_wait'
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { resolveContextGcMode } from '../model/configuration.js';
|
|
2
1
|
import { restoreMessages } from '../runtime/context/restore.js';
|
|
3
2
|
import { latestModelUsage, reasoningEffortBaseline } from '../runtime/context/usage.js';
|
|
4
3
|
import { publicModelUsage } from '../runtime/event-projection.js';
|
|
@@ -578,7 +577,7 @@ export function createSessionExecutionFactory(ports) {
|
|
|
578
577
|
executionId,
|
|
579
578
|
turnId
|
|
580
579
|
});
|
|
581
|
-
const contextGcMode =
|
|
580
|
+
const contextGcMode = selectedModel.contextGcMode ?? 'off';
|
|
582
581
|
const contextCoordinator = new ExecutionContextCoordinator({
|
|
583
582
|
initialBoundary: restoredMessageCount,
|
|
584
583
|
messages,
|
|
@@ -842,6 +842,7 @@ function triggerMatchesRecords(records, recordsBySequence, payload) {
|
|
|
842
842
|
(!usageRecord ||
|
|
843
843
|
!isRecord(usageRecord.payload) ||
|
|
844
844
|
usageRecord.payload.type !== 'usage.updated' ||
|
|
845
|
+
usageRecord.payload.purpose === 'compact' ||
|
|
845
846
|
modelContextUsage(usageRecord.payload) !== payload.trigger.contextInputTokens))
|
|
846
847
|
return false;
|
|
847
848
|
const baseSequence = contextGcBaseSequence(payload.base);
|
|
@@ -871,6 +872,7 @@ function triggerMatchesRecords(records, recordsBySequence, payload) {
|
|
|
871
872
|
if (matchingConfiguration &&
|
|
872
873
|
isRecord(record.payload) &&
|
|
873
874
|
record.payload.type === 'usage.updated' &&
|
|
875
|
+
record.payload.purpose !== 'compact' &&
|
|
874
876
|
modelContextUsage(record.payload) !== undefined)
|
|
875
877
|
latestMatchingUsageSequence = record.sequence;
|
|
876
878
|
if (matchingConfiguration &&
|