fix(subagent): gate model selection with explicit allowlist

This commit is contained in:
Dudu-0223
2026-08-27 12:00:02 +08:00
parent ebe8d4db1c
commit 7c626fb5d2
71 changed files with 498 additions and 971 deletions
@@ -124,7 +124,6 @@
config:
provider: spawn
toolName: subagent
enableModelSelection: true
backgroundMode: continuable
maxDepth: 1
+6 -2
View File
@@ -242,12 +242,16 @@ describe('the shipped Web composition', () => {
})
it('applies the default-off subagent model allowlist only to new sessions', async () => {
await ctx.settings.update(SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, { allowedModels: [] })
await ctx.settings.update(SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, {
enabled: false,
allowedModels: [],
})
const disabled = await ctx.agents.create({
sessionId: SessionId('preset-model-selection-disabled'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
await ctx.settings.update(SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, {
enabled: true,
allowedModels: [{ provider: 'deepseek-official', model: 'deepseek-v4-flash' }],
})
const enabled = await ctx.agents.create({
@@ -265,7 +269,7 @@ describe('the shipped Web composition', () => {
]))
expect(toolNames(ctx, disabled.agent)).not.toContain('list_subagent_models')
} finally {
await ctx.settings.update(SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, { allowedModels: [] })
await ctx.settings.update(SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, { enabled: false })
await enabled.dispose()
await disabled.dispose()
}
+10
View File
@@ -106,10 +106,20 @@ describe('web e2e: plugin configuration section', () => {
await expect.poll(() => toggle.getAttribute('aria-checked'), { timeout: 5_000 }).toBe('true')
await expect.poll(async () => (await settingsDocument()).includes('subagent-model-selection:'), { timeout: 10_000 })
.toBe(true)
expect(await settingsDocument()).toContain('enabled: true')
expect(await settingsDocument()).toContain('allowedModels:')
expect(await settingsDocument()).toContain('provider:')
expect(await settingsDocument()).toContain('model:')
expect(await dialog.getByRole('status').textContent()).toBe('已保存,新会话将使用此设置。')
await toggle.click()
await dialog.getByRole('button', { name: '保存', exact: true }).click()
await expect.poll(() => toggle.getAttribute('aria-checked'), { timeout: 5_000 }).toBe('false')
await expect.poll(async () => (await settingsDocument()).includes('enabled: false'), { timeout: 10_000 })
.toBe(true)
expect(await settingsDocument()).toContain('allowedModels:')
expect(await settingsDocument()).toContain('provider:')
expect(await settingsDocument()).toContain('model:')
expect(tripwire.pageErrors).toEqual([])
}, 60_000)