mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 23:08:36 +00:00
Tests: the real-Harness /compact test no longer depends on how long the temp path is
"the real Harness lands the selected evidence through /compact and reuses it on the next turn" failed on every Linux run with the 0.2.24 AppImage Harness
(and passed on Windows). The scripted model answers a tool result with "Tool finished. Result: " plus the first 120 characters of it, whitespace collapsed, and the
read tool's result starts with the file's absolute path: under /tmp that is 47 characters, which puts the cut at exactly 120 characters, in the middle of the
evidence on the file's first line ("1: FINAL_TEST_EVIDENCE: 12 pass"). The Harness bundle (patches, commit) has nothing to do with it: the same failure shows with the
unpatched Windows search and MCP files swapped in.
The scripted worker takes echoChars (default 120, so every other test is unchanged) and this test asks for 240, which leaves room for a path of about 160 characters.
Passes on Linux against the extracted 0.2.24 AppImage Harness (14 of 14 with the pin tests).
This commit is contained in:
1 parent
3766287fca
commit
3064cfd487
2 files changed
+9
-4
No files matched your search
@@ -143,7 +143,10 @@ const harness = !!process.env.STRATA_HARNESS_DIR && resolveHarness({ env: proces
|
||||
test('the real Harness lands the selected evidence through /compact and reuses it on the next turn', { skip: !harness }, async t => {
|
||||
const { config, calls } = await server(t);
|
||||
const window = 65536;
|
||||
const worker = await startScriptedWorker({ window, charsPerToken: 3, chunkDelayMs: 1 });
|
||||
// The scripted model repeats the first 120 characters of the read result, which begin with the file's absolute path: under /tmp on Linux (47 characters here) the
|
||||
// evidence on the file's first line was cut to "12 pass" and the test failed on every Linux run (0.2.24 AppImage Harness and the Windows one alike). The
|
||||
// evidence must not depend on how long the temp path is, so the worker repeats 240 (a temp path of up to about 160 characters).
|
||||
const worker = await startScriptedWorker({ window, charsPerToken: 3, chunkDelayMs: 1, echoChars: 240 });
|
||||
const dir = mkdtempSync(join(tmpdir(), 'strata-optimizer-harness-'));
|
||||
writeFileSync(join(dir, 'report.txt'), 'FINAL_TEST_EVIDENCE: 12 passed.\n' + 'routine output\n'.repeat(400));
|
||||
let selected = config;
|
||||
|
||||
@@ -40,7 +40,9 @@ import { createHash } from 'node:crypto';
|
||||
|
||||
const delay = ms => new Promise(r => setTimeout(r, ms));
|
||||
|
||||
export async function startScriptedWorker({ port = 0, chunkDelayMs = 40, model = 'scripted-model', serial = false, window = 0, charsPerToken = 0, noCount = false } = {}) {
|
||||
export async function startScriptedWorker({ port = 0, chunkDelayMs = 40, model = 'scripted-model', serial = false, window = 0, charsPerToken = 0, noCount = false, echoChars = 120 } = {}) {
|
||||
// `echoChars`: how much of a tool result the answer "Tool finished. Result: ..." repeats (whitespace collapsed). The read tool's result starts with the file's
|
||||
// absolute path, so a test that needs something from further in the result must raise this above the longest temp path it may run under.
|
||||
// `window` + `charsPerToken` make it behave like the engine: every request's prompt is counted (its size over charsPerToken), the usage it
|
||||
// reports is that count, and a prompt that leaves no room to answer is refused with the engine's own 400 ("requests are never truncated").
|
||||
// `serial` stands in for an engine with one request slot: the next request waits until the one before it has finished.
|
||||
@@ -245,7 +247,7 @@ export async function startScriptedWorker({ port = 0, chunkDelayMs = 40, model =
|
||||
return say([String(cfg.say ?? 'Done.')]);
|
||||
}
|
||||
if (last.role === 'tool') {
|
||||
const result = text(last).replace(/\s+/g, ' ').slice(0, 120);
|
||||
const result = text(last).replace(/\s+/g, ' ').slice(0, echoChars);
|
||||
return say(['Tool finished. ', `Result: ${result}`]);
|
||||
}
|
||||
const [name, args] = [directive?.[1], (directive?.[2] ?? '').trim()];
|
||||
@@ -271,7 +273,7 @@ export async function startScriptedWorker({ port = 0, chunkDelayMs = 40, model =
|
||||
if (name === 'read') return toolCall('read', { file_path: args });
|
||||
if (name === 'call') {
|
||||
// This prompt's one call already ran (the Harness may add a context message after its result): answer, never call twice.
|
||||
if (toolMessages.length) return say(['Tool finished. ', `Result: ${text(toolMessages[toolMessages.length - 1]).replace(/\s+/g, ' ').slice(0, 120)}`]);
|
||||
if (toolMessages.length) return say(['Tool finished. ', `Result: ${text(toolMessages[toolMessages.length - 1]).replace(/\s+/g, ' ').slice(0, echoChars)}`]);
|
||||
const at = args.indexOf(' ');
|
||||
let callArgs = {};
|
||||
try { callArgs = JSON.parse(at < 0 ? '{}' : args.slice(at + 1).replace(/\s+#\d+.*$/, '')); } catch { /* an unparsable script argument is a test bug; send no arguments */ }
|
||||
|
||||
Reference in new issue
Block a user