Skip to content

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

An autopilot run with no chosen generation limit grows it to the shots left (#11104)

[._.]/4c671196e7ca
diff --git a/server/lib/musicVideoAutonomous.js b/server/lib/musicVideoAutonomous.js
index b3d4a811b9..4c69cd44ac 100644
--- a/server/lib/musicVideoAutonomous.js
+++ b/server/lib/musicVideoAutonomous.js
@@ -223,6 +223,8 @@ function normalizeAutonomousSettings(raw = {}) {
maxGenerations: int(raw.limits?.maxGenerations, AUTONOMOUS_LIMIT_BOUNDS.maxGenerations, AUTONOMOUS_DEFAULT_LIMITS.maxGenerations),
maxReviewAttempts: int(raw.limits?.maxReviewAttempts, AUTONOMOUS_LIMIT_BOUNDS.maxReviewAttempts, AUTONOMOUS_DEFAULT_LIMITS.maxReviewAttempts),
},
+ // No generation limit was chosen, so production sizes the default to the planned shots.
+ ...(raw.limits?.maxGenerations == null || raw.sizedGenerations === true ? { sizedGenerations: true } : {}),
checkpoints,
// An existing mood board to reuse instead of generating one (blank = generate).
moodBoardId: clean(raw.moodBoardId, 64) || null,
diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.js
index b3a9ca1a2b..e96cc79e19 100644
--- a/server/services/musicVideo/autonomousService.js
+++ b/server/services/musicVideo/autonomousService.js
@@ -69,9 +69,10 @@ import { getMusicVideoCharacterStyle } from '../../lib/musicVideoCharacterStyles
import { RENDER_TARGET } from '../../lib/renderTargets.js';
import { IMAGE_GEN_MODE } from '../../lib/generationModes.js';
import { assertFootageVideoModelsCapable, loadPoolEnv } from './productionPool.js';
-import { PRODUCTION_RESUMABLE_STATUSES } from './production.js';
+import { PRODUCTION_RESUMABLE_STATUSES, productionTargets } from './production.js';
import {
AUTONOMOUS_DEFAULT_LIMITS,
+ AUTONOMOUS_LIMIT_BOUNDS,
AUTONOMOUS_LIVE_STATUSES,
AUTONOMOUS_STAGE_IDS,
autonomousLyricsReviewEnabled,
@@ -1640,6 +1641,8 @@ export async function resumeAutonomousVideo(projectId, edits = {}, { autoApprove
...(stillsApproved ? { stopBeforeVideo: false } : {}),
...(modelsPatch ? { models: modelsPatch } : {}),
...(limitsPatch ? { limits: limitsPatch } : {}),
+ // A generation limit the director sets replaces the sized default.
+ ...(edits.limits?.maxGenerations != null ? { sizedGenerations: false } : {}),
...(edits.suno ? { suno: normalizeSunoOptions({ ...r.brief.suno, ...edits.suno }) } : {}),
...(edits.localMusic !== undefined ? { localMusic: normalizeLocalMusicOptions(edits.localMusic ? { ...r.brief.localMusic, ...edits.localMusic } : null) } : {}),
...(grant || {}),
@@ -1803,6 +1806,28 @@ export async function cancelAutonomousVideo(projectId) {
const PRODUCTION_PARKED = new Set(['limit-reached', 'blocked', 'needs-replan', 'needs-human', 'stopped']);
+/**
+ * A run whose director chose no generation limit outgrows the default: when
+ * production stops at its generation limit with stills or clips still to make,
+ * the limit becomes what is spent plus two per shot left (a retry or
+ * regeneration each), within the bound, and production resumes. Returns
+ * whether it did; a chosen limit, or one already that high, parks as before.
+ */
+async function raiseSizedLimit(projectId, runId, run, project, production) {
+ const limit = production.limits?.maxGenerations || 0;
+ const used = production.usage?.generations || 0;
+ if (!run.brief.sizedGenerations || used < limit) return false;
+ const targets = productionTargets(project);
+ const left = targets.frame.filter((scene) => !scene.referenceImageId).length
+ + (production.stopBefore === 'clips' ? 0 : targets.clip.filter((scene) => !scene.videoHistoryId).length);
+ const raised = Math.min(used + left * 2, AUTONOMOUS_LIMIT_BOUNDS.maxGenerations.max);
+ if (raised <= limit) return false;
+ const resumed = await deps.resumeProduction(projectId, runId, { acceptBasis: true, limits: { maxGenerations: raised } })
+ .then(() => true, (err) => { console.warn(`⚠️ Autonomous music video ${short(run.id)} could not raise its generation limit: ${err.message}`); return false; });
+ if (resumed) console.log(`🎬 Autonomous music video ${short(run.id)} raised its default generation limit to ${raised} for ${left} shot${left === 1 ? '' : 's'} left`);
+ return resumed;
+}
+
/**
* A production run this autonomous run delegated to advanced. Mirrors its
* terminal state onto the run: completed → kick off the final render and
@@ -1829,6 +1854,8 @@ async function onProductionEvent({ projectId, runId, run: production }) {
await park(projectId, 'needs-human', { error: reason || 'Production was canceled', errorCode: 'PRODUCTION_CANCELED' });
} else if (production.status === 'awaiting-video') {
if (run.status === 'running') await settleStills(projectId, run, runId);
+ } else if (production.status === 'limit-reached' && run.status === 'running' && await raiseSizedLimit(projectId, runId, run, project, production)) {
+ // The default generation limit grew to the planned shots and production goes on.
} else if (PRODUCTION_PARKED.has(production.status) && run.status === 'running') {
await park(projectId, 'needs-human', { error: reason || `Production is ${production.status}`, errorCode: 'PRODUCTION_PARKED' });
}
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index 27f4c4ef73..312eaa02ec 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -1475,6 +1475,27 @@ describe('orchestrated mode (brief.orchestrator)', () => {
expect(doubles.resumeProduction.mock.calls[0][2].stopBefore).toBeUndefined();
});
+ // Uniquely catches a 69-shot run parking at the default 40 generations before every shot has a still.
+ it('grows a default generation limit to the shots left, but parks at a limit the director chose', async () => {
+ await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local'], orchestrator: ORCHESTRATOR }, { autoApproveAuthorized: true });
+ await vi.waitFor(() => expect(doubles.startProduction).toHaveBeenCalledOnce());
+ store.get('mv-auto').scenes = Array.from({ length: 30 }, (_, i) => ({ sceneId: `mvs-${i}`, label: `Shot ${i}`, framePrompt: 'a skater', ...(i < 5 ? { referenceImageId: `s${i}.png` } : {}) }));
+ const limited = { status: 'limit-reached', stopBefore: 'clips', limits: { maxGenerations: 40 }, usage: { generations: 40 } };
+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: limited });
+ expect(doubles.resumeProduction).toHaveBeenCalledWith('mv-auto', 'mvpr-1', { acceptBasis: true, limits: { maxGenerations: 90 } });
+ expect(runOf().status).toBe('running');
+
+ store.delete('mv-auto');
+ doubles.startProduction.mockClear();
+ doubles.resumeProduction.mockClear();
+ await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local'], orchestrator: ORCHESTRATOR, limits: { maxGenerations: 40 } }, { autoApproveAuthorized: true });
+ await vi.waitFor(() => expect(doubles.startProduction).toHaveBeenCalledOnce());
+ store.get('mv-auto').scenes = [{ sceneId: 'mvs-a', label: 'Intro', framePrompt: 'a skater' }];
+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: limited });
+ expect(doubles.resumeProduction).not.toHaveBeenCalled();
+ expect(runOf()).toMatchObject({ status: 'needs-human', errorCode: 'PRODUCTION_PARKED' });
+ });
+
// Uniquely catches an unviewable still being recorded as an approved review while the run still waits for the director.
it('does not record approval for stills the reviewer could not see', async () => {
await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local'], orchestrator: ORCHESTRATOR }, { autoApproveAuthorized: true });
diff --git a/server/services/musicVideo/production.js b/server/services/musicVideo/production.js
index 210dba3f29..ef8922ab91 100644
--- a/server/services/musicVideo/production.js
+++ b/server/services/musicVideo/production.js
@@ -368,7 +368,7 @@ export function assertProductionActive(project, runId, processId) {
}
/** The scenes that need a still frame and a clip, per the project's render mode. */
-function productionTargets(project) {
+export function productionTargets(project) {
const assets = codeFirstProductionAssets(project);
if (assets) {
const ids = (action) => new Set(assets.steps.filter((step) => step.action === action).map((step) => step.sceneId));