Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
retry a batched section that fails its source check instead of failing the document
[._.]/ Adam Eivy75a9864201e5
diff --git a/server/services/musicVideo/documentGeneration.js b/server/services/musicVideo/documentGeneration.jsindex f88c7b7c56..a67c177e85 100644--- a/server/services/musicVideo/documentGeneration.js+++ b/server/services/musicVideo/documentGeneration.js@@ -229,13 +229,20 @@ function batchSectionIds(ids, promptFor, budget) {return batches;}-// The requested section functions a response carries (possibly fewer than asked for).-function returnedSections(text, ids) {+// The requested section functions a response carries (possibly fewer than asked for). With+// `lenient`, a section that fails its source check is left out (to be retried) instead of+// failing the whole answer.+function returnedSections(text, ids, { lenient = false } = {}) {const wanted = new Set(ids);const accepted = new Map();for (const entry of extractCodeSections(text)) {if (!wanted.has(entry.id) || accepted.has(entry.id)) continue;- accepted.set(entry.id, checkedFunction(entry.source));+ try {+ accepted.set(entry.id, checkedFunction(entry.source));+ } catch (err) {+ if (!lenient) throw err;+ console.warn(`⚠️ Music-video document: section ${entry.id} failed its source check (${err.message}); retrying it on its own`);+ }}return accepted;}@@ -334,10 +341,10 @@ async function runAuthoring(projectId, { providerId, model, effort, sectionId =console.log(`🎬 Music-video document prompt is ${fullPrompt.length} chars; authoring ${ids.length} sections in ${batches.length} batches on a local model`);for (const batch of batches) {run = await runBatch(withFeedback(promptFor(batch)));- const returned = returnedSections(run.text, batch);+ const returned = returnedSections(run.text, batch, { lenient: true });for (const [id, source] of returned) updated.set(id, source);- // A local model often drops a section or breaks the JSON of a multi-section answer:- // ask once more for each missing section on its own before giving up.+ // A local model often drops a section, breaks the JSON of a multi-section answer or+ // writes one section that fails its check: ask once more for each on its own.for (const id of batch.filter((sectionId) => !returned.has(sectionId))) {console.log(`🎬 Music-video document: re-authoring section ${id} on its own (missing from its batch)`);run = await runBatch(withFeedback(promptFor([id])));diff --git a/server/services/musicVideo/documentGeneration.test.js b/server/services/musicVideo/documentGeneration.test.jsindex 93e8830f4d..b83b135db1 100644--- a/server/services/musicVideo/documentGeneration.test.js+++ b/server/services/musicVideo/documentGeneration.test.js@@ -151,6 +151,16 @@ describe('treatment-driven mixed-media document authoring', () => {expect(manifest.sections.every((s) => s.source.includes('function render'))).toBe(true);expect(h.calls).toBeGreaterThan(2);+ // A returned section that fails its source check is retried on its own too.+ h.onSubmit = async () => {+ const asked = sectionsAsked(h.prompt);+ h.response = asked.length > 1+ ? JSON.stringify({ sections: asked.map((s, i) => ({ id: s, source: i === asked.length - 1 ? 'function render(ctx, env) { ctx.fillRect(Math.random(), 0, 1, 1); }' : source('#010203') })) })+ : all;+ };+ const retried = await manifestAt((await generateMixedMediaDocument(id, { providerId: 'ollama', promptBudgetChars: budget })).document);+ expect(retried.sections.every((s) => !s.source.includes('Math.random'))).toBe(true);+// The retry missing it too is a hard failure naming the count.h.onSubmit = async () => { h.response = response({ intro: '#010203' }); };await expect(generateMixedMediaDocument(id, { providerId: 'ollama', promptBudgetChars: budget }))