feat: verify owned DeepSeek engine connections and responsive task execution

This commit is contained in:
Agent Workbench Dev
2026-10-30 07:25:09 +08:00
parent 1d8abaceab
commit 91981c1400
69 changed files with 4068 additions and 50 deletions
+43
View File
@@ -19,6 +19,49 @@ function commandProvider(command) {
return provider;
}
test('a stop from the event loop interrupts immediate model replies before later tools', async t => {
const f = fixture(t), provider = new Provider();
let replies = 0, stopped;
const runtime = new Runtime(f.store, provider); f.onCleanup(() => runtime.stopAll());
provider.complete = async () => {
replies++;
if (replies === 1) setImmediate(() => { stopped = runtime.stop(f.session.id); });
return { message: { role: 'assistant', content: 'Controlled immediate reply.',
...(replies <= 6 ? { tool_calls: [call('immediate-' + replies, 'list_files', { path: '', depth: 1 })] } : {}) }, usage: null };
};
runtime.start(f.session.id, 'Inspect this owned fixture; allow an incoming stop to take effect.');
await runtime.active.get(f.session.id).promise;
await new Promise(resolve => setImmediate(resolve)); await stopped;
assert.equal(f.session.status, 'paused', 'The event loop must process the stop before the task finishes.');
assert.equal(replies, 1, 'A completed tool must be persisted before stop prevents the next model reply.');
const tools = [...f.store.core.tool.values()].filter(value => value.sessionId === f.session.id);
assert.equal(tools.length, 1); assert.equal(tools[0].state, 'completed');
assert.equal(f.store.core.run.get(f.session.runId).stopReason, 'cancelled');
assertToolPairs(f.session.providerMessages);
});
test('a stop after the first tool preserves a complete interrupted multi-call protocol group', async t => {
const f = fixture(t), provider = new Provider(), runtime = new Runtime(f.store, provider);
f.onCleanup(() => runtime.stopAll());
let scheduled = false, stopped;
f.store.on('update', () => {
if (!scheduled && f.session.events.some(value => value.toolCallId === 'fair-batch-0' && value.phase === 'completed')) {
scheduled = true; setImmediate(() => { stopped = runtime.stop(f.session.id); });
}
});
provider.complete = async () => ({ message: { role: 'assistant', content: 'Controlled immediate multi-tool reply.',
tool_calls: Array.from({ length: 6 }, (_, index) => call('fair-batch-' + index, 'list_files', { path: '', depth: 1 })) }, usage: null });
runtime.start(f.session.id, 'Inspect this fixture and accept a stop before later batched calls.');
await runtime.active.get(f.session.id).promise;
await new Promise(resolve => setImmediate(resolve)); await stopped;
assert.equal(f.session.status, 'paused');
const tools = [...f.store.core.tool.values()].filter(value => value.sessionId === f.session.id);
assert.equal(tools.length, 6); assert.equal(tools[0].state, 'completed');
assert.ok(tools.slice(1).every(value => value.state === 'interrupted' && !value.requiresVerification));
assertToolPairs(f.session.providerMessages);
assert.equal(f.session.providerMessages.filter(value => value.role === 'tool').length, 6);
});
test('the compatible HTTP loop preserves call IDs, validates errors and waits before executing commands', async t => {
const f = fixture(t);
const command = 'node -e "require(\'node:fs\').writeFileSync(\'approved.txt\',\'ok\'); console.log(\'fixture-command\')"';