fix: distinguish read-only evidence from file delivery requirements
This commit is contained in:
@@ -5,7 +5,7 @@ import path from 'node:path';
|
||||
import { Runtime } from '../src/server/runtime.mjs';
|
||||
import { Provider } from '../src/server/provider.mjs';
|
||||
import { applyChange } from '../src/server/files.mjs';
|
||||
import { isDiagnosticQuestion } from '../src/shared/contracts/task-control.mjs';
|
||||
import { isDiagnosticQuestion, taskContract } from '../src/shared/contracts/task-control.mjs';
|
||||
import { fixture, call, assertToolPairs } from './helpers.mjs';
|
||||
|
||||
const answer = content => ({ message: { role: 'assistant', content }, usage: { prompt_tokens: 11, completion_tokens: 3 } });
|
||||
@@ -15,6 +15,19 @@ test('operational questions are diagnostic while explicit repair requests remain
|
||||
for (const text of ['先修复系统', '为什么失败,请帮我修复', '这个错误怎么回事,然后修一下', 'fix this error', '继续完成']) assert.equal(isDiagnosticQuestion(text), false, text);
|
||||
});
|
||||
|
||||
test('file delivery requires a positive instruction, not saved evidence or a prohibited write', () => {
|
||||
for (const goal of ['读取保存的原工件,分段取得真实依据,不执行命令或修改文件。',
|
||||
'读取保存过的 HTML 文件并解释内容', '不要创建文件,只分析结果', '读取工件,不执行命令或创建文件',
|
||||
'Do not create a file; explain the evidence.', 'Read the saved file without creating HTML.']) {
|
||||
assert.equal(taskContract({ goal }).kind, 'general', goal);
|
||||
}
|
||||
for (const goal of ['创建一个 HTML 文件,无需测试', '新建 result.txt', '把结果保存为 report.md 文件',
|
||||
'请写入 SVG 文件', 'Create an HTML file without running tests.', '不要执行命令,创建一个 HTML 文件',
|
||||
'文件不存在时创建 report.md 文件', '不要修改原有文件而是新建 HTML 文件']) {
|
||||
assert.equal(taskContract({ goal }).kind, 'file', goal);
|
||||
}
|
||||
});
|
||||
|
||||
test('an unsubstantiated text claim cannot complete a requested file delivery', async t => {
|
||||
const f = harness(t, () => answer('HTML 已创建完成。'));
|
||||
f.runtime.start(f.session.id, '创建一个 HTML 文件,无需测试'); await f.wait();
|
||||
|
||||
Reference in New Issue
Block a user