okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Agent watchdog: the engine's prompt-read progress counts as activity; local routes get a 60 min stream-idle timeout (#3623)425bca719

main
1.5 KiB23 linesraw
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import { engineProgressMark } from '../server/agent/engine-progress.mjs';
4import { readFileSync } from 'node:fs';
5
6test('the mark moves with the prompt read and with generation, and is null when the engine is idle or silent', () => {
7  const at = live => engineProgressMark({ metrics: { live } });
8  assert.equal(engineProgressMark(null), null);
9  assert.equal(engineProgressMark({ metrics: null }), null);
10  assert.equal(at({ state: 'idle' }), null);
11  assert.equal(at({ state: 'unloaded' }), null);
12  const a = at({ state: 'reading', prompt_read: 4096, prompt_total: 90000 });
13  const b = at({ state: 'reading', prompt_read: 8192, prompt_total: 90000 });
14  assert.notEqual(a, b);
15  assert.equal(a, at({ state: 'reading', prompt_read: 4096, prompt_total: 90000 }), 'no progress, same mark');
16  assert.notEqual(at({ state: 'generating', generated: 1 }), at({ state: 'generating', generated: 2 }));
17  assert.notEqual(at({ state: 'reading', slots: [{ state: 'reading', prompt_read: 1 }] }), at({ state: 'reading', slots: [{ state: 'reading', prompt_read: 2 }] }));
18});
19
20test('the host wires it in and the local profile lifts the 300 s stream-idle timer', () => {
21  assert.match(readFileSync(new URL('../server/index.mjs', import.meta.url), 'utf8'), /engineProgress: instanceId => engineProgressMark\(/);
22  assert.match(readFileSync(new URL('../server/agent/profile.mjs', import.meta.url), 'utf8'), /streamIdleTimeoutMs: 60 \* 60_000/);
23});