A model server on this network keeps half its window for the reply (long Time-skip steps overflowed the window); Time-skip says why A failed

This commit is contained in:
Niko1221 committed 2026-10-16 23:18:34 +02:00
1 parent 30a367e5f4
commit 17ba2d71ad
3 files changed
+11 -3

No files matched your search

+5 -2
View File
@@ -220,6 +220,9 @@ export function buildProfile({ local = [], connections = [], gate = true, tools
// A model server on this computer or network (another Strata PC, llama.cpp, LM Studio) takes the same thinking vocabulary as a local model:
// without it the Reasoning menu did nothing for a connection to another Strata machine.
const ownServer = protocol === 'openai-completions' && isPrivateHost(baseURL);
// A model server on this computer or network has a window of its own size like a local model: the reply keeps half of it, so the Harness can compact the conversation
// before the window is full (with nearly all of it reserved for the reply a long task ended with "the prompt leaves no room to answer").
const reply = m => (ownServer && Number.isFinite(m.contextMax) && m.contextMax > 0 && !m.maxOutput ? localOutputBudget(m.contextMax) : outputBudget(m.contextMax ?? ASSUMED_API_CONTEXT, m.maxOutput));
providers[route] = {
displayName: conn.name,
api: protocol,
@@ -228,14 +231,14 @@ export function buildProfile({ local = [], connections = [], gate = true, tools
...(ownServer ? { compat: THINKING_COMPAT } : {}),
models: conn.models.map(m => ({
id: m.id, name: m.name || m.id,
contextWindow: m.contextMax ?? ASSUMED_API_CONTEXT, maxTokens: outputBudget(m.contextMax ?? ASSUMED_API_CONTEXT, m.maxOutput),
contextWindow: m.contextMax ?? ASSUMED_API_CONTEXT, maxTokens: reply(m),
input: ownServer ? ['text', 'image'] : ['text'],
...(ownServer ? { reasoning: true, reasoningEfforts: LOCAL_EFFORTS } : {}),
})),
};
const fp = fingerprint(providers[route], conn.apiKey ?? '');
const shaped = ownServer ? addShaped(route, providers[route], baseURL) : null;
for (const m of conn.models) { const ctx = m.contextMax ?? ASSUMED_API_CONTEXT; compaction.push({ provider: route, model: m.id, headroomTokens: compactionHeadroom(ctx, outputBudget(ctx, m.maxOutput)) }); }
for (const m of conn.models) { const ctx = m.contextMax ?? ASSUMED_API_CONTEXT; compaction.push({ provider: route, model: m.id, headroomTokens: compactionHeadroom(ctx, reply(m)) }); }
for (const m of conn.models) routes.push({ route, fp, kind: 'api', connectionId: conn.id, modelId: m.id, name: m.name || m.id, contextWindow: m.contextMax ?? ASSUMED_API_CONTEXT, ...(shaped ? { shaped } : {}) });
});
+3 -1
View File
@@ -174,6 +174,8 @@ export function createForkTimeskip({ agent, dir, notify = () => {}, now = Date.n
r.a.state = 'running'; r.a.total = plan.steps.length; setPhase(r, 'generating'); announce(r);
await agent.planGoal({ chatId: aChat, planId: plan.id, workspacePath: r.a.root, mode: 'bypass', choice, thinking,
onFrame: f => {
if (f.type === 'error') r.a.note = String(f.message ?? '').slice(0, 240);
if (f.type === 'goal' && f.goal) r.a.goal = { phase: f.goal.phase, blocked: f.goal.blocked ?? null, round: f.goal.round };
if (f.type === 'plan-step') {
r.a.step = f.index; r.a.total = f.total; r.a.text = f.text; r.a.line = f.line;
if (f.state === 'done') { r.a.summaries.push(`${f.index}. ${f.text}${f.summary ? ': ' + f.summary : ''}`); if (r.lever && f.index === 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.' }; } } }
@@ -184,7 +186,7 @@ export function createForkTimeskip({ agent, dir, notify = () => {}, now = Date.n
const aEnd = agent.planState(aChat);
r.a.state = aEnd?.state === 'done' ? 'done' : 'failed';
announce(r);
if (r.a.state !== 'done') throw new Error('A did not finish the plan, so there is nothing to compare. Your files were not changed.');
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(); }
if (r.lever && slots < 2 && r.b.state === 'waiting') { say(r, 'b-waiting', 'A is done. B starts now (one model slot: B waited for A).'); bDone = startB(); }
if (bDone) await bDone.catch(e => { r.b.state = 'failed'; r.b.note = 'B stopped: ' + String(e.message ?? e).slice(0, 160); });
+3
View File
@@ -54,6 +54,9 @@ test('the profile adds a response-settings copy of each shapeable route (local,
assert.equal(providers['api-lan'].compat.thinkingFormat, 'chat-template', 'a model server on this network gets the thinking vocabulary of a local model');
assert.equal(providers['api-lan'].models[0].reasoning, true);
assert.equal(providers['api-cloud'].compat, undefined, 'a cloud service does not');
const small = buildProfile({ local: [], connections: [{ id: 'own', name: 'Own', baseUrl: 'http://127.0.0.1:18798/v1', protocol: 'openai-chat', apiKey: '', models: [{ id: 'm', contextMax: 32768 }] }] });
const own = JSON.parse(small.patch.slice(small.patch.indexOf('['))).find(e => e.id === 'llm-pi-ai').config.providers['api-own'];
assert.equal(own.models[0].maxTokens, 16384, 'a server on this network keeps half its window for the reply so long tasks can be compacted (it was 28672 of 32768: no room, no compaction)');
assert.match(profile.patch, /"baseURL": "http:\/\/127\.0\.0\.1:8791\/api\/internal\/agent-llm\/strata-local~s8192\/v1"/);
assert.match(profile.patch, /"x-strata-budget": "8192"/);
assert.match(profile.patch, /"provider": "strata-local~s8192"/, 'compaction keeps its timing on the copy too');