fix: seal pause inputs before publishing a terminal run state

This commit is contained in:
Agent Workbench Dev
2026-11-01 13:41:32 +08:00
parent 3f1c026195
commit 0efc3450d2
3 changed files with 31 additions and 5 deletions
+21
View File
@@ -99,6 +99,27 @@ test('a provider cannot execute tests against an explicit no-test task even if i
assertToolPairs(f.session.providerMessages);
});
test('a budget pause becomes visible only after its input snapshot can be sealed with the original Run', async t => {
const f = harness(t, () => calls(call('one-read', 'read_file', { path: 'README.md' })));
f.store.config.maxSteps = 1;
let entered, release;
const capturing = new Promise(resolve => { entered = resolve; });
const held = new Promise(resolve => { release = resolve; });
const capture = f.runtime.capturePauseInputs.bind(f.runtime);
f.runtime.capturePauseInputs = async run => { entered(); await held; return capture(run); };
t.after(() => release());
f.runtime.start(f.session.id, '读取原文件');
await capturing;
const run = f.store.core.run.get(f.session.runId);
assert.equal(f.session.status, 'running'); assert.equal(run.finishedAt, null);
assert.equal(f.runtime.isActive(f.session.id), true);
assert.throws(() => f.runtime.resume(f.session.id), { status: 409 });
release(); await f.wait();
assert.equal(f.session.status, 'paused'); assert.equal(run.stopReason, 'step_limit');
assert.ok(run.finishedAt); assert.ok(run.finalSourceFingerprint);
assert.equal(f.runtime.isActive(f.session.id), false);
});
test('alternating duplicate file reads and listing files still pauses without treating new pages as duplicates', async t => {
const f = harness(t, round => calls(call('duplicate-read-' + round, 'read_file', { path: round % 2 ? 'README.md' : 'second.txt' }), call('list-between-' + round, 'list_files', { path: '' })));
fs.writeFileSync(path.join(f.projectRoot, 'second.txt'), 'another original source\n');