dsh-context-compression-improved 0.6.0 → 0.6.1
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 +162 -162
- package/packages/selector/package.json +114 -114
- package/packages/selector/tests/code-skeleton.client.spec.ts +93 -93
- package/packages/selector/tests/helpers/legacy-namespace.ts +31 -31
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -206
- package/packages/selector/tests/preset-options-write.client.spec.ts +1 -1
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +206 -206
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +3 -3
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +20 -20
- package/packages/selector/tests/standing-generation.host.spec.ts +704 -704
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import { pathToFileURL } from 'node:url'
|
|
5
|
-
import { Context } from '@deepseek-ai/cordis'
|
|
6
|
-
import Group from '@deepseek-ai/cordis-plugin-group'
|
|
7
|
-
import Include from '@deepseek-ai/cordis-plugin-include'
|
|
8
|
-
import { Config } from '../src/index.ts'
|
|
9
|
-
import Loader from '@deepseek-ai/cordis-plugin-loader'
|
|
10
|
-
import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
|
|
11
|
-
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
|
|
12
|
-
import AgentPresets, { COMPOSITION_FILE } from '@deepseek-ai/dsh-agent-presets'
|
|
13
|
-
import CommandRuntime from '@deepseek-ai/dsh-commands'
|
|
14
|
-
import LlmRuntime from '@deepseek-ai/dsh-llm'
|
|
15
|
-
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
|
|
16
|
-
import { scopeOf } from '@deepseek-ai/dsh-scope'
|
|
17
|
-
import {
|
|
18
|
-
SettingsProvider,
|
|
19
|
-
type SettingsNamespace,
|
|
20
|
-
} from '@deepseek-ai/dsh-settings'
|
|
21
|
-
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
|
|
22
|
-
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
|
23
|
-
import TokenMeter from '@deepseek-ai/dsh-token-meter'
|
|
24
|
-
import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
25
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
26
|
-
import { apply } from '../src/index.ts'
|
|
27
|
-
import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
|
|
28
|
-
|
|
29
|
-
// 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
|
|
30
|
-
const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
|
|
31
|
-
|
|
32
|
-
const CORDIS_ORIGINAL = Symbol.for('cordis.original')
|
|
33
|
-
type Traceable = { [CORDIS_ORIGINAL]?: unknown }
|
|
34
|
-
|
|
35
|
-
let ctx: Context | undefined
|
|
36
|
-
let root: string | undefined
|
|
37
|
-
|
|
38
|
-
afterEach(async () => {
|
|
39
|
-
await ctx?.fiber.dispose()
|
|
40
|
-
ctx = undefined
|
|
41
|
-
if (root !== undefined) await rm(root, { recursive: true, force: true })
|
|
42
|
-
root = undefined
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
class MemorySettings extends SettingsProvider {
|
|
46
|
-
readonly writable = true
|
|
47
|
-
|
|
48
|
-
protected load(): Promise<Record<string, unknown>> {
|
|
49
|
-
return Promise.resolve({})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
|
|
53
|
-
return Promise.resolve()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface CustomSettings {
|
|
58
|
-
profile: string
|
|
59
|
-
custom: {
|
|
60
|
-
history: { trigger: number }
|
|
61
|
-
tailTrim: { enabled: boolean; trigger: number }
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async function createPresetRoot(): Promise<string> {
|
|
66
|
-
root = await mkdtemp(join(tmpdir(), 'dsh-selector-loader-e2e-'))
|
|
67
|
-
const marker = join(root, 'marker.mjs')
|
|
68
|
-
await writeFile(marker, 'export function apply() {}\n')
|
|
69
|
-
const source = `- id: source-marker\n name: ${JSON.stringify(marker)}\n`
|
|
70
|
-
for (const id of ['standard', 'custom', 'minimal']) {
|
|
71
|
-
const directory = join(root, id)
|
|
72
|
-
await mkdir(directory)
|
|
73
|
-
await writeFile(join(directory, COMPOSITION_FILE), source)
|
|
74
|
-
}
|
|
75
|
-
return root
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function harness(): Promise<Context> {
|
|
79
|
-
const presets = await createPresetRoot()
|
|
80
|
-
const runtime = new Context()
|
|
81
|
-
runtime.baseUrl = `${pathToFileURL(presets).href}/`
|
|
82
|
-
await runtime.plugin(Loader).await()
|
|
83
|
-
runtime.loader.builtins.include = Include
|
|
84
|
-
runtime.loader.builtins.group = Group
|
|
85
|
-
await runtime.plugin(LlmRuntime).await()
|
|
86
|
-
await runtime.plugin(SessionStore).await()
|
|
87
|
-
await runtime.plugin(SystemPrompt).await()
|
|
88
|
-
await runtime.plugin(ToolRuntime).await()
|
|
89
|
-
await runtime.plugin(AgentRegistry).await()
|
|
90
|
-
await runtime.plugin(AgentLoop).await()
|
|
91
|
-
await runtime.plugin(CommandRuntime).await()
|
|
92
|
-
await runtime.plugin(SessionProjectionRegistry).await()
|
|
93
|
-
await runtime.plugin(TokenMeter).await()
|
|
94
|
-
await runtime.plugin(MemorySettings).await()
|
|
95
|
-
await runtime.plugin(AgentPresets, {
|
|
96
|
-
default: 'standard',
|
|
97
|
-
roots: [{ path: presets, trust: 'system' }],
|
|
98
|
-
includeShippedRoot: false,
|
|
99
|
-
includeUserRoot: false,
|
|
100
|
-
})
|
|
101
|
-
await runtime.plugin({
|
|
102
|
-
apply: (selectorCtx) => {
|
|
103
|
-
apply(selectorCtx, { presetOverlay: true })
|
|
104
|
-
},
|
|
105
|
-
}).await()
|
|
106
|
-
ctx = runtime
|
|
107
|
-
return runtime
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function agentOn(runtime: Context, sessionId: string, preset: string): Promise<Agent> {
|
|
111
|
-
const handle = await runtime.agents.create({
|
|
112
|
-
sessionId: SessionId(sessionId),
|
|
113
|
-
setup: async agentCtx => void await runtime.agentPresets.mount(agentCtx, preset),
|
|
114
|
-
})
|
|
115
|
-
return handle.agent
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function hasCompressionRetrieve(runtime: Context, agent: Agent): boolean {
|
|
119
|
-
return runtime.tools.get('context_compression_retrieve', scopeOf(agent.ctx)) !== undefined
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function hasCompactCommand(runtime: Context, agent: Agent): boolean {
|
|
123
|
-
return runtime.commands.list(agent).some(command => command.name === 'compact')
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function expectCompleteCompressionStack(runtime: Context, agent: Agent): void {
|
|
127
|
-
expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeDefined()
|
|
128
|
-
expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeDefined()
|
|
129
|
-
expect(hasCompressionRetrieve(runtime, agent)).toBe(true)
|
|
130
|
-
expect(hasCompactCommand(runtime, agent)).toBe(true)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function expectNoCompressionStack(runtime: Context, agent: Agent): void {
|
|
134
|
-
expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeUndefined()
|
|
135
|
-
expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeUndefined()
|
|
136
|
-
expect(hasCompressionRetrieve(runtime, agent)).toBe(false)
|
|
137
|
-
expect(hasCompactCommand(runtime, agent)).toBe(false)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
describe('standalone selector Bundle through the real preset Loader', () => {
|
|
141
|
-
it('mounts the complete stack without changing source preset authoring', async () => {
|
|
142
|
-
const runtime = await harness()
|
|
143
|
-
const source = await runtime.agentPresets.resolve('standard')
|
|
144
|
-
const sourceText = await runtime.agentPresets.read('standard')
|
|
145
|
-
|
|
146
|
-
const agent = await agentOn(runtime, 'selector-loader-standard', 'standard')
|
|
147
|
-
|
|
148
|
-
expectCompleteCompressionStack(runtime, agent)
|
|
149
|
-
expect((await runtime.agentPresets.resolve('standard')).path).toBe(source.path)
|
|
150
|
-
expect(await runtime.agentPresets.read('standard')).toBe(sourceText)
|
|
151
|
-
expect(sourceText).not.toContain('tool-result-pruner')
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it('keeps compression across preset changes and excludes only exact Minimal', async () => {
|
|
155
|
-
const runtime = await harness()
|
|
156
|
-
const agent = await agentOn(runtime, 'selector-loader-switch', 'standard')
|
|
157
|
-
expectCompleteCompressionStack(runtime, agent)
|
|
158
|
-
|
|
159
|
-
await runtime.agentPresets.recompose(agent.ctx, 'minimal')
|
|
160
|
-
expectNoCompressionStack(runtime, agent)
|
|
161
|
-
|
|
162
|
-
// `custom` deliberately contains the same source rows as Minimal. Its id,
|
|
163
|
-
// not its copied contents, decides the one documented exception.
|
|
164
|
-
await runtime.agentPresets.recompose(agent.ctx, 'custom')
|
|
165
|
-
expectCompleteCompressionStack(runtime, agent)
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('gives a child the parent\'s exact compression service instances', async () => {
|
|
169
|
-
const runtime = await harness()
|
|
170
|
-
const parent = await agentOn(runtime, 'selector-loader-parent', 'standard')
|
|
171
|
-
const childHandle = await runtime.agents.create({
|
|
172
|
-
sessionId: SessionId('selector-loader-child'),
|
|
173
|
-
setup: childCtx => void runtime.agentPresets.composeFrom(childCtx, parent.ctx),
|
|
174
|
-
})
|
|
175
|
-
const child = childHandle.agent
|
|
176
|
-
|
|
177
|
-
const parentPruner = runtime.agentPresets.serviceFor(parent, 'toolResultPruner')
|
|
178
|
-
const childPruner = runtime.agentPresets.serviceFor(child, 'toolResultPruner')
|
|
179
|
-
const parentCompaction = runtime.agentPresets.serviceFor(parent, 'compaction')
|
|
180
|
-
const childCompaction = runtime.agentPresets.serviceFor(child, 'compaction')
|
|
181
|
-
expect(parentPruner).toBeDefined()
|
|
182
|
-
expect(parentCompaction).toBeDefined()
|
|
183
|
-
expect(Object.is(
|
|
184
|
-
(childPruner as Traceable)[CORDIS_ORIGINAL],
|
|
185
|
-
(parentPruner as Traceable)[CORDIS_ORIGINAL],
|
|
186
|
-
)).toBe(true)
|
|
187
|
-
expect(Object.is(
|
|
188
|
-
(childCompaction as Traceable)[CORDIS_ORIGINAL],
|
|
189
|
-
(parentCompaction as Traceable)[CORDIS_ORIGINAL],
|
|
190
|
-
)).toBe(true)
|
|
191
|
-
expect(hasCompressionRetrieve(runtime, child)).toBe(true)
|
|
192
|
-
expect(hasCompactCommand(runtime, child)).toBe(true)
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
it('carries the daily Custom defaults on the bundle entry config schema', async () => {
|
|
196
|
-
// 0.1.7: there is no plugin-owned settings row publishing defaults — the
|
|
197
|
-
// volatile `settings` field's schema defaults ARE the daily Custom doc the
|
|
198
|
-
// loader resolves into every composition.
|
|
199
|
-
const settings = (Config({ presetOverlay: true }).settings as unknown as {
|
|
200
|
-
get(): CustomSettings
|
|
201
|
-
}).get()
|
|
202
|
-
|
|
203
|
-
expect(settings.custom.history.trigger).toBe(500_000)
|
|
204
|
-
expect(settings.custom.tailTrim).toEqual({ enabled: false, trigger: 700_000 })
|
|
205
|
-
})
|
|
206
|
-
})
|
|
1
|
+
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { pathToFileURL } from 'node:url'
|
|
5
|
+
import { Context } from '@deepseek-ai/cordis'
|
|
6
|
+
import Group from '@deepseek-ai/cordis-plugin-group'
|
|
7
|
+
import Include from '@deepseek-ai/cordis-plugin-include'
|
|
8
|
+
import { Config } from '../src/index.ts'
|
|
9
|
+
import Loader from '@deepseek-ai/cordis-plugin-loader'
|
|
10
|
+
import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
|
|
11
|
+
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
|
|
12
|
+
import AgentPresets, { COMPOSITION_FILE } from '@deepseek-ai/dsh-agent-presets'
|
|
13
|
+
import CommandRuntime from '@deepseek-ai/dsh-commands'
|
|
14
|
+
import LlmRuntime from '@deepseek-ai/dsh-llm'
|
|
15
|
+
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
|
|
16
|
+
import { scopeOf } from '@deepseek-ai/dsh-scope'
|
|
17
|
+
import {
|
|
18
|
+
SettingsProvider,
|
|
19
|
+
type SettingsNamespace,
|
|
20
|
+
} from '@deepseek-ai/dsh-settings'
|
|
21
|
+
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
|
|
22
|
+
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
|
23
|
+
import TokenMeter from '@deepseek-ai/dsh-token-meter'
|
|
24
|
+
import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
25
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
26
|
+
import { apply } from '../src/index.ts'
|
|
27
|
+
import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
|
|
28
|
+
|
|
29
|
+
// 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
|
|
30
|
+
const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
|
|
31
|
+
|
|
32
|
+
const CORDIS_ORIGINAL = Symbol.for('cordis.original')
|
|
33
|
+
type Traceable = { [CORDIS_ORIGINAL]?: unknown }
|
|
34
|
+
|
|
35
|
+
let ctx: Context | undefined
|
|
36
|
+
let root: string | undefined
|
|
37
|
+
|
|
38
|
+
afterEach(async () => {
|
|
39
|
+
await ctx?.fiber.dispose()
|
|
40
|
+
ctx = undefined
|
|
41
|
+
if (root !== undefined) await rm(root, { recursive: true, force: true })
|
|
42
|
+
root = undefined
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
class MemorySettings extends SettingsProvider {
|
|
46
|
+
readonly writable = true
|
|
47
|
+
|
|
48
|
+
protected load(): Promise<Record<string, unknown>> {
|
|
49
|
+
return Promise.resolve({})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
|
|
53
|
+
return Promise.resolve()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface CustomSettings {
|
|
58
|
+
profile: string
|
|
59
|
+
custom: {
|
|
60
|
+
history: { trigger: number }
|
|
61
|
+
tailTrim: { enabled: boolean; trigger: number }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function createPresetRoot(): Promise<string> {
|
|
66
|
+
root = await mkdtemp(join(tmpdir(), 'dsh-selector-loader-e2e-'))
|
|
67
|
+
const marker = join(root, 'marker.mjs')
|
|
68
|
+
await writeFile(marker, 'export function apply() {}\n')
|
|
69
|
+
const source = `- id: source-marker\n name: ${JSON.stringify(marker)}\n`
|
|
70
|
+
for (const id of ['standard', 'custom', 'minimal']) {
|
|
71
|
+
const directory = join(root, id)
|
|
72
|
+
await mkdir(directory)
|
|
73
|
+
await writeFile(join(directory, COMPOSITION_FILE), source)
|
|
74
|
+
}
|
|
75
|
+
return root
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function harness(): Promise<Context> {
|
|
79
|
+
const presets = await createPresetRoot()
|
|
80
|
+
const runtime = new Context()
|
|
81
|
+
runtime.baseUrl = `${pathToFileURL(presets).href}/`
|
|
82
|
+
await runtime.plugin(Loader).await()
|
|
83
|
+
runtime.loader.builtins.include = Include
|
|
84
|
+
runtime.loader.builtins.group = Group
|
|
85
|
+
await runtime.plugin(LlmRuntime).await()
|
|
86
|
+
await runtime.plugin(SessionStore).await()
|
|
87
|
+
await runtime.plugin(SystemPrompt).await()
|
|
88
|
+
await runtime.plugin(ToolRuntime).await()
|
|
89
|
+
await runtime.plugin(AgentRegistry).await()
|
|
90
|
+
await runtime.plugin(AgentLoop).await()
|
|
91
|
+
await runtime.plugin(CommandRuntime).await()
|
|
92
|
+
await runtime.plugin(SessionProjectionRegistry).await()
|
|
93
|
+
await runtime.plugin(TokenMeter).await()
|
|
94
|
+
await runtime.plugin(MemorySettings).await()
|
|
95
|
+
await runtime.plugin(AgentPresets, {
|
|
96
|
+
default: 'standard',
|
|
97
|
+
roots: [{ path: presets, trust: 'system' }],
|
|
98
|
+
includeShippedRoot: false,
|
|
99
|
+
includeUserRoot: false,
|
|
100
|
+
})
|
|
101
|
+
await runtime.plugin({
|
|
102
|
+
apply: (selectorCtx) => {
|
|
103
|
+
apply(selectorCtx, { presetOverlay: true })
|
|
104
|
+
},
|
|
105
|
+
}).await()
|
|
106
|
+
ctx = runtime
|
|
107
|
+
return runtime
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function agentOn(runtime: Context, sessionId: string, preset: string): Promise<Agent> {
|
|
111
|
+
const handle = await runtime.agents.create({
|
|
112
|
+
sessionId: SessionId(sessionId),
|
|
113
|
+
setup: async agentCtx => void await runtime.agentPresets.mount(agentCtx, preset),
|
|
114
|
+
})
|
|
115
|
+
return handle.agent
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function hasCompressionRetrieve(runtime: Context, agent: Agent): boolean {
|
|
119
|
+
return runtime.tools.get('context_compression_retrieve', scopeOf(agent.ctx)) !== undefined
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function hasCompactCommand(runtime: Context, agent: Agent): boolean {
|
|
123
|
+
return runtime.commands.list(agent).some(command => command.name === 'compact')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function expectCompleteCompressionStack(runtime: Context, agent: Agent): void {
|
|
127
|
+
expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeDefined()
|
|
128
|
+
expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeDefined()
|
|
129
|
+
expect(hasCompressionRetrieve(runtime, agent)).toBe(true)
|
|
130
|
+
expect(hasCompactCommand(runtime, agent)).toBe(true)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function expectNoCompressionStack(runtime: Context, agent: Agent): void {
|
|
134
|
+
expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeUndefined()
|
|
135
|
+
expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeUndefined()
|
|
136
|
+
expect(hasCompressionRetrieve(runtime, agent)).toBe(false)
|
|
137
|
+
expect(hasCompactCommand(runtime, agent)).toBe(false)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
describe('standalone selector Bundle through the real preset Loader', () => {
|
|
141
|
+
it('mounts the complete stack without changing source preset authoring', async () => {
|
|
142
|
+
const runtime = await harness()
|
|
143
|
+
const source = await runtime.agentPresets.resolve('standard')
|
|
144
|
+
const sourceText = await runtime.agentPresets.read('standard')
|
|
145
|
+
|
|
146
|
+
const agent = await agentOn(runtime, 'selector-loader-standard', 'standard')
|
|
147
|
+
|
|
148
|
+
expectCompleteCompressionStack(runtime, agent)
|
|
149
|
+
expect((await runtime.agentPresets.resolve('standard')).path).toBe(source.path)
|
|
150
|
+
expect(await runtime.agentPresets.read('standard')).toBe(sourceText)
|
|
151
|
+
expect(sourceText).not.toContain('tool-result-pruner')
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('keeps compression across preset changes and excludes only exact Minimal', async () => {
|
|
155
|
+
const runtime = await harness()
|
|
156
|
+
const agent = await agentOn(runtime, 'selector-loader-switch', 'standard')
|
|
157
|
+
expectCompleteCompressionStack(runtime, agent)
|
|
158
|
+
|
|
159
|
+
await runtime.agentPresets.recompose(agent.ctx, 'minimal')
|
|
160
|
+
expectNoCompressionStack(runtime, agent)
|
|
161
|
+
|
|
162
|
+
// `custom` deliberately contains the same source rows as Minimal. Its id,
|
|
163
|
+
// not its copied contents, decides the one documented exception.
|
|
164
|
+
await runtime.agentPresets.recompose(agent.ctx, 'custom')
|
|
165
|
+
expectCompleteCompressionStack(runtime, agent)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('gives a child the parent\'s exact compression service instances', async () => {
|
|
169
|
+
const runtime = await harness()
|
|
170
|
+
const parent = await agentOn(runtime, 'selector-loader-parent', 'standard')
|
|
171
|
+
const childHandle = await runtime.agents.create({
|
|
172
|
+
sessionId: SessionId('selector-loader-child'),
|
|
173
|
+
setup: childCtx => void runtime.agentPresets.composeFrom(childCtx, parent.ctx),
|
|
174
|
+
})
|
|
175
|
+
const child = childHandle.agent
|
|
176
|
+
|
|
177
|
+
const parentPruner = runtime.agentPresets.serviceFor(parent, 'toolResultPruner')
|
|
178
|
+
const childPruner = runtime.agentPresets.serviceFor(child, 'toolResultPruner')
|
|
179
|
+
const parentCompaction = runtime.agentPresets.serviceFor(parent, 'compaction')
|
|
180
|
+
const childCompaction = runtime.agentPresets.serviceFor(child, 'compaction')
|
|
181
|
+
expect(parentPruner).toBeDefined()
|
|
182
|
+
expect(parentCompaction).toBeDefined()
|
|
183
|
+
expect(Object.is(
|
|
184
|
+
(childPruner as Traceable)[CORDIS_ORIGINAL],
|
|
185
|
+
(parentPruner as Traceable)[CORDIS_ORIGINAL],
|
|
186
|
+
)).toBe(true)
|
|
187
|
+
expect(Object.is(
|
|
188
|
+
(childCompaction as Traceable)[CORDIS_ORIGINAL],
|
|
189
|
+
(parentCompaction as Traceable)[CORDIS_ORIGINAL],
|
|
190
|
+
)).toBe(true)
|
|
191
|
+
expect(hasCompressionRetrieve(runtime, child)).toBe(true)
|
|
192
|
+
expect(hasCompactCommand(runtime, child)).toBe(true)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('carries the daily Custom defaults on the bundle entry config schema', async () => {
|
|
196
|
+
// 0.1.7: there is no plugin-owned settings row publishing defaults — the
|
|
197
|
+
// volatile `settings` field's schema defaults ARE the daily Custom doc the
|
|
198
|
+
// loader resolves into every composition.
|
|
199
|
+
const settings = (Config({ presetOverlay: true }).settings as unknown as {
|
|
200
|
+
get(): CustomSettings
|
|
201
|
+
}).get()
|
|
202
|
+
|
|
203
|
+
expect(settings.custom.history.trigger).toBe(500_000)
|
|
204
|
+
expect(settings.custom.tailTrim).toEqual({ enabled: false, trigger: 700_000 })
|
|
205
|
+
})
|
|
206
|
+
})
|
|
@@ -31,7 +31,7 @@ import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
|
|
31
31
|
import TokenMeter from '@deepseek-ai/dsh-token-meter'
|
|
32
32
|
import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
33
33
|
import * as SelectorHost from '../../src/index.ts'
|
|
34
|
-
import { LegacyNamespaceRegistrar } from '../helpers/legacy-namespace.ts'
|
|
34
|
+
import { LegacyNamespaceRegistrar } from '../helpers/legacy-namespace.ts'
|
|
35
35
|
import ToolResultPruner, {
|
|
36
36
|
CONTEXT_COMPRESSION_SETTINGS_NAMESPACE,
|
|
37
37
|
} from '../../src/pruner.ts'
|
|
@@ -136,7 +136,7 @@ function appendToolTurn(session: Session, turn: number, text: string): void {
|
|
|
136
136
|
*/
|
|
137
137
|
async function gatedSettings(ctx: Context): Promise<void> {
|
|
138
138
|
await ctx.plugin(TestSettings).await()
|
|
139
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
139
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
140
140
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
141
141
|
profile: 'tokenpilot-inspired',
|
|
142
142
|
presetOptions: { reviewMode: true, reviewHighImpactTokens: 1 },
|
|
@@ -208,7 +208,7 @@ describe('advice never withholds (retired review gate)', () => {
|
|
|
208
208
|
it('keeps the automatic path identical when no legacy gate key is present', async () => {
|
|
209
209
|
const ctx = await runtimeContext()
|
|
210
210
|
await ctx.plugin(TestSettings).await()
|
|
211
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
211
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
212
212
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
213
213
|
profile: 'tokenpilot-inspired',
|
|
214
214
|
})
|
|
@@ -36,7 +36,7 @@ import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
|
36
36
|
import { CompactionId } from '@deepseek-ai/dsh-compaction'
|
|
37
37
|
import InvariantRegistry from '@deepseek-ai/dsh-invariants'
|
|
38
38
|
import * as SelectorHost from '../../../src/index.ts'
|
|
39
|
-
import { LegacyNamespaceRegistrar } from '../../helpers/legacy-namespace.ts'
|
|
39
|
+
import { LegacyNamespaceRegistrar } from '../../helpers/legacy-namespace.ts'
|
|
40
40
|
import * as RuntimeInvariant from '../../../src/invariant.ts'
|
|
41
41
|
import { sessionEvents } from '../../../src/runtime/session-events.ts'
|
|
42
42
|
import ToolResultPruner, {
|
|
@@ -425,7 +425,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
425
425
|
// replacement → audit record) without ever touching the replacement text.
|
|
426
426
|
const ctx = await runtimeContext()
|
|
427
427
|
await ctx.plugin(TestSettings).await()
|
|
428
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
428
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
429
429
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
430
430
|
profile: 'balanced',
|
|
431
431
|
codeSkeleton: { enabled: true },
|
|
@@ -590,7 +590,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
590
590
|
it('moves the capacity-pressure gate with the frozen Auto Compact threshold', async () => {
|
|
591
591
|
const ctx = await runtimeContext()
|
|
592
592
|
await ctx.plugin(TestSettings).await()
|
|
593
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
593
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
594
594
|
const audit = captureAudit(ctx)
|
|
595
595
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
596
596
|
|
|
@@ -626,7 +626,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
626
626
|
it('ages History earlier when the frozen Auto Compact threshold is low', async () => {
|
|
627
627
|
const ctx = await runtimeContext()
|
|
628
628
|
await ctx.plugin(TestSettings).await()
|
|
629
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
629
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
630
630
|
const audit = captureAudit(ctx)
|
|
631
631
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
632
632
|
|
|
@@ -660,7 +660,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
660
660
|
it('freezes the generation-owned threshold over later global settings changes', async () => {
|
|
661
661
|
const ctx = await runtimeContext()
|
|
662
662
|
await ctx.plugin(TestSettings).await()
|
|
663
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
663
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
664
664
|
const audit = captureAudit(ctx)
|
|
665
665
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
666
666
|
// The preset overlay captured 70% into this generation's deployment
|
|
@@ -696,7 +696,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
696
696
|
it('fails open to a lossless frozen policy when stored settings are malformed', async () => {
|
|
697
697
|
const ctx = await runtimeContext()
|
|
698
698
|
await ctx.plugin(TestSettings).await()
|
|
699
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
699
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
700
700
|
const audit = captureAudit(ctx)
|
|
701
701
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
702
702
|
// A hand-edited store can surface a document the schema rejects (unknown
|
|
@@ -746,7 +746,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
746
746
|
])('fails open to a lossless frozen policy when the stored document carries %s', async (label, malformed) => {
|
|
747
747
|
const ctx = await runtimeContext()
|
|
748
748
|
await ctx.plugin(TestSettings).await()
|
|
749
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
749
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
750
750
|
const audit = captureAudit(ctx)
|
|
751
751
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
752
752
|
// Schemastery `.default(...)` would silently replace these present-but-null
|
|
@@ -783,7 +783,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
783
783
|
|
|
784
784
|
const ctx = await runtimeContext()
|
|
785
785
|
await ctx.plugin(TestSettings).await()
|
|
786
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
786
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
787
787
|
const audit = captureAudit(ctx)
|
|
788
788
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
789
789
|
const malformed = {
|
|
@@ -883,7 +883,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
883
883
|
it('audits the Auto Compact coordination block on policy resolution', async () => {
|
|
884
884
|
const ctx = await runtimeContext()
|
|
885
885
|
await ctx.plugin(TestSettings).await()
|
|
886
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
886
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
887
887
|
const audit = captureAudit(ctx)
|
|
888
888
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
889
889
|
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
@@ -920,7 +920,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
920
920
|
const overrideCtx = await runtimeContext()
|
|
921
921
|
await overrideCtx.plugin(TestSettings).await()
|
|
922
922
|
await overrideCtx.plugin(SelectorHost).await()
|
|
923
|
-
await overrideCtx.plugin(LegacyNamespaceRegistrar).await()
|
|
923
|
+
await overrideCtx.plugin(LegacyNamespaceRegistrar).await()
|
|
924
924
|
const overrideAudit = captureAudit(overrideCtx)
|
|
925
925
|
await overrideCtx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
926
926
|
await overrideCtx.plugin(ToolResultPruner, {
|
|
@@ -946,7 +946,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
946
946
|
const mixedCtx = await runtimeContext()
|
|
947
947
|
await mixedCtx.plugin(TestSettings).await()
|
|
948
948
|
await mixedCtx.plugin(SelectorHost).await()
|
|
949
|
-
await mixedCtx.plugin(LegacyNamespaceRegistrar).await()
|
|
949
|
+
await mixedCtx.plugin(LegacyNamespaceRegistrar).await()
|
|
950
950
|
const mixedAudit = captureAudit(mixedCtx)
|
|
951
951
|
await mixedCtx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
952
952
|
await mixedCtx.plugin(ToolResultPruner, {
|
|
@@ -982,7 +982,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
982
982
|
it('freezes the Auto Compact threshold per Session and applies new values only to new Sessions', async () => {
|
|
983
983
|
const ctx = await runtimeContext()
|
|
984
984
|
await ctx.plugin(TestSettings).await()
|
|
985
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
985
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
986
986
|
const audit = captureAudit(ctx)
|
|
987
987
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
988
988
|
await ctx.plugin(ToolResultPruner, { profile: 'balanced' }).await()
|
|
@@ -1506,7 +1506,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1506
1506
|
it('still commits unlinked Custom History batches at the minimum reclaim', async () => {
|
|
1507
1507
|
const ctx = await runtimeContext()
|
|
1508
1508
|
await ctx.plugin(TestSettings).await()
|
|
1509
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1509
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1510
1510
|
const audit = captureAudit(ctx)
|
|
1511
1511
|
// A protected token tail larger than the trigger leaves the linked-style
|
|
1512
1512
|
// whole-excess demand unreachable; Custom stays manual and must still
|
|
@@ -1692,7 +1692,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1692
1692
|
const ctx = new Context()
|
|
1693
1693
|
activeContexts.push(ctx)
|
|
1694
1694
|
await ctx.plugin(TestSettings).await()
|
|
1695
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1695
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1696
1696
|
await ctx.plugin(SessionStore).await()
|
|
1697
1697
|
await ctx.plugin(SystemPrompt).await()
|
|
1698
1698
|
await ctx.plugin(ToolRuntime).await()
|
|
@@ -1754,7 +1754,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1754
1754
|
const ctx = new Context()
|
|
1755
1755
|
activeContexts.push(ctx)
|
|
1756
1756
|
await ctx.plugin(TestSettings).await()
|
|
1757
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1757
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1758
1758
|
await ctx.plugin(SessionStore).await()
|
|
1759
1759
|
await ctx.plugin(SystemPrompt).await()
|
|
1760
1760
|
await ctx.plugin(ToolRuntime).await()
|
|
@@ -1851,7 +1851,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1851
1851
|
const ctx = new Context()
|
|
1852
1852
|
activeContexts.push(ctx)
|
|
1853
1853
|
await ctx.plugin(TestSettings).await()
|
|
1854
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1854
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1855
1855
|
await ctx.plugin(SessionStore).await()
|
|
1856
1856
|
await ctx.plugin(SystemPrompt).await()
|
|
1857
1857
|
await ctx.plugin(ToolRuntime).await()
|
|
@@ -1944,7 +1944,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1944
1944
|
const ctx = new Context()
|
|
1945
1945
|
activeContexts.push(ctx)
|
|
1946
1946
|
await ctx.plugin(TestSettings).await()
|
|
1947
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1947
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1948
1948
|
await ctx.plugin(SessionStore).await()
|
|
1949
1949
|
await ctx.plugin(InvariantRegistry).await()
|
|
1950
1950
|
await ctx.plugin(RuntimeInvariant).await()
|
|
@@ -2124,7 +2124,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
2124
2124
|
const ctx = new Context()
|
|
2125
2125
|
activeContexts.push(ctx)
|
|
2126
2126
|
await ctx.plugin(TestSettings).await()
|
|
2127
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2127
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2128
2128
|
await ctx.plugin(LlmRuntime).await()
|
|
2129
2129
|
await ctx.plugin(SessionStore).await()
|
|
2130
2130
|
await ctx.plugin(SystemPrompt).await()
|
|
@@ -2571,7 +2571,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
2571
2571
|
it('never TailTrims a tool group whose results carry images', async () => {
|
|
2572
2572
|
const ctx = await runtimeContext()
|
|
2573
2573
|
await ctx.plugin(TestSettings).await()
|
|
2574
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2574
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2575
2575
|
const audit = captureAudit(ctx)
|
|
2576
2576
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
2577
2577
|
profile: 'custom',
|
|
@@ -2663,7 +2663,7 @@ describe('character basis / model-id independence', () => {
|
|
|
2663
2663
|
async function characterBasisContext(): Promise<Context> {
|
|
2664
2664
|
const ctx = await runtimeContext()
|
|
2665
2665
|
await ctx.plugin(TestSettings).await()
|
|
2666
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2666
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2667
2667
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
2668
2668
|
profile: 'balanced',
|
|
2669
2669
|
codeSkeleton: { enabled: true },
|