Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Time-skip: view-in-browser steps never hang or fail a version (no-window rule, skip with a plain note); steps carry the unattended note

Niko12217b1405e10454
diff --git a/apps/host/server/agent/agent-bridge.mjs b/apps/host/server/agent/agent-bridge.mjs
index ed1cd29f6..07ceed363 100644
--- a/apps/host/server/agent/agent-bridge.mjs
+++ b/apps/host/server/agent/agent-bridge.mjs
@@ -944,6 +944,9 @@ export function createAgentBridge({ dataDir, componentsDir = null, bundledDir =
/** A paused plan becomes open again (a step that did not finish is tried again in a fresh session). */
function reopenPlan(chatId) { const p = plans.get(chatId); if (p && p.state === 'paused') { plans.update(chatId, x => { x.state = 'approved'; }); onPlan(chatId, 'approved', planView(plans.get(chatId))); } }
+ /** Give up on one step with a plain note (a check that cannot be done here) so the rest of the plan can go on. */
+ function skipStep(chatId, index, note) { plans.update(chatId, p => { const st = p.steps[index]; if (st) { st.state = 'skipped'; st.summary = String(note ?? 'Skipped.').slice(0, 140); } if (p.state === 'paused') p.state = 'approved'; }); onPlan(chatId, 'step', planView(plans.get(chatId))); }
+
/** Forget the chat's agent session (not its plan): the next turn starts a fresh one in the same folder. */
function resetSession(chatId) {
if (chats.get(chatId)?.turn || chats.get(chatId)?.starting) throw new AgentUnavailable('This chat is still working.', 'turn-active');
@@ -1086,7 +1089,7 @@ export function createAgentBridge({ dataDir, componentsDir = null, bundledDir =
/** Let go of a chat's Harness session mapping (a task starts every run in a session of its own). */
function forget(chatId) { if (chats.get(chatId)?.turn) return; delete sessionMap[chatId]; chats.delete(chatId); persist(); }
- return { goalState, goalControl, harnessDir, status, runTurn, goalCommand, planCommand, researchCommand, llmTarget, setPlanBriefing, resetSession, reopenPlan, planGoal, planControl, planState, queueMessage, cancelQueued, takeQueue, forget, approve, setMode, stop, pendingFor, close, sessionOf: chatId => sessionMap[chatId]?.sessionId ?? null, isRunning: chatId => !!chats.get(chatId)?.turn, _debug: () => ({ rt, sessionMap }) };
+ return { goalState, goalControl, harnessDir, status, runTurn, goalCommand, planCommand, researchCommand, llmTarget, setPlanBriefing, resetSession, reopenPlan, skipStep, planGoal, planControl, planState, queueMessage, cancelQueued, takeQueue, forget, approve, setMode, stop, pendingFor, close, sessionOf: chatId => sessionMap[chatId]?.sessionId ?? null, isRunning: chatId => !!chats.get(chatId)?.turn, _debug: () => ({ rt, sessionMap }) };
}
/** A goal that stopped by itself, in words. */
diff --git a/apps/host/server/agent/plan.mjs b/apps/host/server/agent/plan.mjs
index 27db8b9e0..066391071 100644
--- a/apps/host/server/agent/plan.mjs
+++ b/apps/host/server/agent/plan.mjs
@@ -105,6 +105,9 @@ export function parsePoints(objective) {
return { title: clip(aim || steps[0].text, 80), steps };
}
+/** A step that is about looking at the result in a browser or window: it must never hang or fail a whole run on a machine with no screen. */
+export const isViewStep = text => /\b(open|view|launch|preview|look at|check|confirm|verify)\b[^\n]{0,60}\b(browser|in chrome|in edge|in firefox|window|on screen)\b/i.test(String(text ?? ''));
+
/** The goal the Harness runs for step `index` (0-based): one step, with the aim and the steps around it named. */
export function stepObjective(plan, index) {
const n = plan.steps.length; const s = plan.steps[index];
@@ -114,6 +117,7 @@ export function stepObjective(plan, index) {
`You are on step ${index + 1} of ${n}: ${s.text}${s.detail ? ` (${s.detail})` : ''}.`,
done ? `Already done: ${done}.` : '',
plan.briefing ? String(plan.briefing) : '',
+ isViewStep(s.text) ? 'This step is about seeing the result in a browser. Never wait for a program to close. If a person is at this computer, start the browser so the command returns at once (Windows: Start-Process; macOS: open; Linux: xdg-open) and say it is open. If there is no screen, check the page without a visible window: use the headless browser tool if you have one, otherwise read the file and its script for mistakes, and say in one plain sentence what you could and could not check. Then finish the step.' : '',
'Do only this step, check that it worked, and then finish the goal.',
index + 1 < n ? 'The next steps are handled separately: do not start them.' : '',
].filter(Boolean).join(' ');
diff --git a/apps/host/server/timeskip-fork.mjs b/apps/host/server/timeskip-fork.mjs
index 87ade9cd5..e7e446686 100644
--- a/apps/host/server/timeskip-fork.mjs
+++ b/apps/host/server/timeskip-fork.mjs
@@ -16,6 +16,10 @@ import { randomUUID } from 'node:crypto';
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { dirname, join, relative, resolve, sep } from 'node:path';
import { diffRun, runImagePath, isNoisePath } from './timeskip.mjs';
+import { isViewStep } from './agent/plan.mjs';
+
+/** The note both agents carry on every step: the work is in a copy, unattended, on whatever machine this is. */
+export const UNATTENDED = 'This work runs in a copy of the folder with nobody watching. Never open a visible window and never wait for a program to close. To check a web page use the headless browser tool if you have one; otherwise read the file and say plainly what you could not check. A check that cannot be done here is noted in one sentence and the step is finished.';
const SKIP = new Set(['.git', '.strata', '.timeskip', 'node_modules', '__pycache__']);
const TERMINAL = new Set(['completed', 'failed', 'cancelled', 'interrupted']);
@@ -118,6 +122,7 @@ export function createForkTimeskip({ agent, dir, notify = () => {}, now = Date.n
if (stopped()) return;
const plan = agent.planState(aChat);
if (!plan || plan.steps.length < 2) throw new Error('The assistant could not split this request into steps. Describe the steps you want, or use /goal instead.');
+ agent.setPlanBriefing(aChat, UNATTENDED);
agent.planControl({ chatId: aChat, planId: plan.id, action: 'approve' });
r.plan = { id: plan.id, title: plan.title, steps: plan.steps.map(s => ({ id: s.id, text: s.text, detail: s.detail })) };
announce(r);
@@ -142,7 +147,7 @@ export function createForkTimeskip({ agent, dir, notify = () => {}, now = Date.n
if (stopped()) return;
const bp = agent.planState(bChat);
if (!bp || bp.steps.length < 2) { r.b.state = 'failed'; r.b.note = 'The improvement plan could not be written, so only A is shown.'; announce(r); return; }
- agent.setPlanBriefing(bChat, 'This work continues from a first attempt that is already in this folder; its notes are in .timeskip/context.md (read them first). Improve on it where it is weak instead of starting over.');
+ agent.setPlanBriefing(bChat, UNATTENDED + ' This work continues from a first attempt that is already in this folder; its notes are in .timeskip/context.md (read them first). Improve on it where it is weak instead of starting over.');
agent.planControl({ chatId: bChat, planId: bp.id, action: 'approve' });
r.b.plan = bp.steps.map(s => ({ id: s.id, text: s.text }));
r.b.state = 'running'; r.b.total = bp.steps.length; announce(r);
@@ -160,10 +165,11 @@ export function createForkTimeskip({ agent, dir, notify = () => {}, now = Date.n
if (stopped()) return;
finished = agent.planState(bChat)?.steps[at]?.state === 'done';
}
- if (agent.planState(bChat)?.steps[at]?.state !== 'done') break;
+ if (agent.planState(bChat)?.steps[at]?.state !== 'done' && isViewStep(bp.steps[at].text)) { agent.skipStep(bChat, at, 'Could not look at the page here; the files were checked instead.'); say(r, 'b-skip', `B, step ${at + 1} (viewing the page) was skipped on this machine.`, { step: at + 1 }); }
+ if (!['done', 'skipped'].includes(agent.planState(bChat)?.steps[at]?.state)) break;
}
const end = agent.planState(bChat);
- r.b.state = end?.steps.every(x => x.state === 'done') ? 'done' : 'failed';
+ r.b.state = end?.steps.every(x => ['done', 'skipped'].includes(x.state)) ? 'done' : 'failed';
if (r.b.state === 'failed') r.b.note = stopped() ? 'Stopped.' : 'B did not finish, so only A is shown.';
announce(r);
};
@@ -205,13 +211,17 @@ export function createForkTimeskip({ agent, dir, notify = () => {}, now = Date.n
if (stopped()) return;
finished = agent.planState(aChat)?.steps[at]?.state === 'done';
}
+ if (agent.planState(aChat)?.steps[at]?.state !== 'done' && isViewStep(plan.steps[at].text)) {
+ // a look-in-a-browser step must not fail the whole version
+ agent.skipStep(aChat, at, 'Could not look at the page here; the files were checked instead.'); say(r, 'a-skip', `A, step ${at + 1} (viewing the page) was skipped on this machine.`, { step: at + 1 });
+ }
const now = agent.planState(aChat);
- if (!now || now.steps[at]?.state !== 'done') break;
+ if (!now || !['done', 'skipped'].includes(now.steps[at]?.state)) break;
if (r.lever && at + 1 === r.lever.step - 1) { try { forkNow(); } catch (e) { r.b = { ...r.b, state: 'failed', note: 'B could not be prepared, so only A is shown.' }; } }
}
if (stopped()) return;
const aEnd = agent.planState(aChat);
- r.a.state = aEnd?.state === 'done' || aEnd?.steps.every(x => x.state === 'done') ? 'done' : 'failed';
+ r.a.state = aEnd?.steps.every(x => ['done', 'skipped'].includes(x.state)) ? 'done' : 'failed';
announce(r);
if (r.a.state !== 'done') throw new Error('A did not finish the plan' + (r.a.note ? ' (' + r.a.note + ')' : r.a.goal?.blocked ? ' (' + r.a.goal.blocked + ')' : '') + ', so there is nothing to compare. Your files were not changed.');
if (r.lever && !forked) { forkNow(); }
diff --git a/apps/host/tests/timeskip-fork.test.mjs b/apps/host/tests/timeskip-fork.test.mjs
index b84431a49..59c7ab96e 100644
--- a/apps/host/tests/timeskip-fork.test.mjs
+++ b/apps/host/tests/timeskip-fork.test.mjs
@@ -7,7 +7,8 @@ import { join } from 'node:path';
import { startScriptedWorker } from './helpers/scripted-worker.mjs';
import { createAgentBridge } from '../server/agent/agent-bridge.mjs';
import { resolveHarness } from '../server/agent/harness-runtime.mjs';
-import { createForkTimeskip, leverPrompt, parseLever, defaultLever, improvementPrompt, copyProject } from '../server/timeskip-fork.mjs';
+import { isViewStep, stepObjective } from '../server/agent/plan.mjs';
+import { UNATTENDED, createForkTimeskip, leverPrompt, parseLever, defaultLever, improvementPrompt, copyProject } from '../server/timeskip-fork.mjs';
const HARNESS = process.env.STRATA_HARNESS_DIR;
const skip = !HARNESS || !resolveHarness({ env: process.env }).ok ? 'STRATA_HARNESS_DIR is not set to a built Harness' : false;
@@ -102,3 +103,10 @@ test('Stop ends both agents, removes the copies and leaves the folder alone', {
assert.equal(readFileSync(join(r.project, 'keep.txt'), 'utf8'), 'original');
assert.equal(r.ts.files(run.id), null);
});
+
+test('a step about looking at the page in a browser is recognised, carries the no-hang rule, and the unattended note forbids windows', () => {
+ assert.ok(isViewStep('Open goku.html in a browser to confirm rendering')); assert.ok(isViewStep('Preview the page in a window')); assert.ok(!isViewStep('Write the HTML file')); assert.ok(!isViewStep('Count the voxels'));
+ const plan = { title: 'T', steps: [{ text: 'Write it' }, { text: 'Open it in a browser to check', detail: '' }] };
+ assert.match(stepObjective(plan, 1), /Never wait for a program to close/); assert.match(stepObjective(plan, 1), /Start-Process/); assert.ok(!/Start-Process/.test(stepObjective(plan, 0)));
+ assert.match(UNATTENDED, /Never open a visible window/);
+});