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

Mark only the prompt's own slot in the agent instructions chip

Claude55c9e03c45b1
diff --git a/client/src/lib/videoGenSubmission.test.js b/client/src/lib/videoGenSubmission.test.js
index a6a1599b92..82d5f77c0f 100644
--- a/client/src/lib/videoGenSubmission.test.js
+++ b/client/src/lib/videoGenSubmission.test.js
@@ -242,3 +242,21 @@ describe('buildVideoGenSubmission — local IC-LoRA, chunks and misc', () => {
expect(local({ steps: 8, guidanceScale: 3, seed: null })).toMatchObject({ steps: 8, guidanceScale: 3, seed: '' });
});
});
+
+describe('buildVideoGenSubmission — prompt additions (#11317)', () => {
+ const preset = { label: 'Film noir', prompt: 'cinematic noir', negativePrompt: '' };
+
+ it('lists the style preset, then the No music line the local lane appends', () => {
+ const payload = buildVideoGenSubmission(baseArgs({ currentModel: {}, stylePreset: preset, noMusic: true }));
+ expect(payload.prompt).toBe('cinematic noir. a fox running through a forest\n\nno music, no soundtrack');
+ expect(payload.promptAdditions).toEqual([
+ { id: 'style-1', label: 'Style preset: Film noir', text: 'cinematic noir' },
+ { id: 'no-music', label: 'No music', text: 'no music, no soundtrack' },
+ ]);
+ });
+
+ it('sends no No music chip on a hosted lane, which never appends it', () => {
+ const payload = buildVideoGenSubmission(baseArgs({ isFal: true, currentModel: {}, stylePreset: preset, noMusic: true }));
+ expect(payload.promptAdditions).toEqual([{ id: 'style-1', label: 'Style preset: Film noir', text: 'cinematic noir' }]);
+ });
+});
diff --git a/client/src/services/apiImageVideo.test.js b/client/src/services/apiImageVideo.test.js
index 36c96a00b4..9592f3bd19 100644
--- a/client/src/services/apiImageVideo.test.js
+++ b/client/src/services/apiImageVideo.test.js
@@ -100,3 +100,15 @@ describe('upscaleAdapterDownloadUrl', () => {
expect(upscaleAdapterDownloadUrl(null)).toBeNull();
});
});
+
+describe('buildFormData', () => {
+ // The route's promptAdditions schema parses one JSON field (#11317); per-item
+ // String() would have sent "[object Object]".
+ it('sends a list of records as one JSON field and keeps scalar lists repeated', async () => {
+ const { buildFormData } = await import('./apiImageVideo.js');
+ const additions = [{ id: 'style-1', label: 'Universe style', text: 'muted earth tones' }];
+ const fd = buildFormData({ promptAdditions: additions, loraScales: [0.8, 1] });
+ expect(fd.getAll('promptAdditions')).toEqual([JSON.stringify(additions)]);
+ expect(fd.getAll('loraScales')).toEqual(['0.8', '1']);
+ });
+});
diff --git a/server/lib/modelInput.js b/server/lib/modelInput.js
index d1dae2258d..81c8bbb86b 100644
--- a/server/lib/modelInput.js
+++ b/server/lib/modelInput.js
@@ -53,10 +53,9 @@ export const promptAdditionsSchema = z.preprocess((value) => {
/**
* An agent backend's instructions around the prompt (Codex, Grok, Antigravity), as one
- * addition: the full message with the prompt itself shown as "[prompt]".
+ * addition: the backend's own builder run with "[prompt]" in the prompt's place, so
+ * the marker lands exactly where the prompt goes and nowhere else.
*/
-export function agentInstructionsAddition(label, fullPrompt, prompt) {
- const own = typeof prompt === 'string' ? prompt.trim() : '';
- const text = own ? String(fullPrompt).split(own).join('[prompt]') : String(fullPrompt);
- return promptAddition('agent-instructions', label, text);
+export function agentInstructionsAddition(label, buildWithPrompt) {
+ return promptAddition('agent-instructions', label, buildWithPrompt('[prompt]'));
}
diff --git a/server/lib/modelInput.test.js b/server/lib/modelInput.test.js
index 85acb46ce1..1f3a5f72f5 100644
--- a/server/lib/modelInput.test.js
+++ b/server/lib/modelInput.test.js
@@ -33,8 +33,11 @@ describe('sentPromptRecord', () => {
});
describe('agentInstructionsAddition', () => {
- it('shows the wrapper with the user prompt marked as [prompt]', () => {
- const addition = agentInstructionsAddition('Codex image tool instructions', 'Generate an image of: a red kite. Save it as PNG.', 'a red kite');
- expect(addition.text).toBe('Generate an image of: [prompt]. Save it as PNG.');
+ // Review on #11326: replacing the prompt text by search garbled the chip when a
+ // short prompt ("image") also appeared inside the wrapper ("$imagegen").
+ it('marks only the spot the builder puts the prompt, even when the wrapper repeats its words', () => {
+ const buildWith = (text) => `$imagegen ${text} of a cat. Aspect ratio 16:9`;
+ expect(agentInstructionsAddition('Codex image tool instructions', buildWith).text)
+ .toBe('$imagegen [prompt] of a cat. Aspect ratio 16:9');
});
});
diff --git a/server/services/imageGen/agy.js b/server/services/imageGen/agy.js
index cdaa66687d..548fabc992 100644
--- a/server/services/imageGen/agy.js
+++ b/server/services/imageGen/agy.js
@@ -302,9 +302,10 @@ export async function generateImage({
const scratchDir = join(tmpdir(), `portos-agy-${jobId}`);
const stagingPath = join(scratchDir, 'output.png');
- const fullPrompt = buildAgyPrompt({
- prompt, negativePrompt, width, height, stagingPath, inputImages, initImageStrength,
+ const buildWith = (text) => buildAgyPrompt({
+ prompt: text, negativePrompt, width, height, stagingPath, inputImages, initImageStrength,
});
+ const fullPrompt = buildWith(prompt);
// `driverModel` is what agy actually runs on — a retired shipped default is
// re-pointed here, so every record below reports the model that rendered
// rather than the one the caller asked for. See resolveAgyDriverModel.
@@ -327,7 +328,7 @@ export async function generateImage({
imageModel: AGY_IMAGEGEN_IMAGE_MODEL,
...(visualConditioning ? { visualConditioning } : {}),
...sentPromptRecord({ sentPrompt: fullPrompt, carried: carriedPromptAdditions({ promptAdditions }),
- added: [agentInstructionsAddition('Antigravity image tool instructions', fullPrompt, prompt)] }),
+ added: [agentInstructionsAddition('Antigravity image tool instructions', buildWith)] }),
createdAt: new Date().toISOString(),
};
// The scratch dir is the last fallible step before the job exists, so a
diff --git a/server/services/imageGen/codex.js b/server/services/imageGen/codex.js
index 63fc47315c..244eb9998c 100644
--- a/server/services/imageGen/codex.js
+++ b/server/services/imageGen/codex.js
@@ -254,7 +254,8 @@ export async function generateImage({
referenceCount: inputImages.referencePaths.length,
initImageStrength,
});
- const fullPrompt = `$imagegen ${editPrefix}${prompt.trim()}${sizeHint}${qualityHint}${avoidHint}`;
+ const buildWith = (text) => `$imagegen ${editPrefix}${text.trim()}${sizeHint}${qualityHint}${avoidHint}`;
+ const fullPrompt = buildWith(prompt);
const bin = codexPath || DEFAULT_BIN;
// `codex exec` treats `-i, --image <FILE>...` as VARIADIC, so it greedily
@@ -288,7 +289,7 @@ export async function generateImage({
filename, mode: IMAGE_GEN_MODE.CODEX, model: effectiveModel,
...(visualConditioning ? { visualConditioning } : {}),
...sentPromptRecord({ sentPrompt: fullPrompt, carried: carriedPromptAdditions({ promptAdditions }),
- added: [agentInstructionsAddition('Codex image tool instructions', fullPrompt, prompt)] }),
+ added: [agentInstructionsAddition('Codex image tool instructions', buildWith)] }),
createdAt: new Date().toISOString(),
};
const job = { ...meta, clients: [], status: 'running', renderStartedAtMs };
diff --git a/server/services/imageGen/grok.js b/server/services/imageGen/grok.js
index 3fefc6ad9c..2a1ad32973 100644
--- a/server/services/imageGen/grok.js
+++ b/server/services/imageGen/grok.js
@@ -258,11 +258,12 @@ export async function generateImage({
const configured = GROK_ASPECT_RATIOS.includes(aspectRatio) ? aspectRatio : null;
const effectiveRatio = derived || configured;
- const fullPrompt = buildGrokPrompt({
- prompt, negativePrompt, aspectRatio: effectiveRatio, stagingPath,
+ const buildWith = (text) => buildGrokPrompt({
+ prompt: text, negativePrompt, aspectRatio: effectiveRatio, stagingPath,
initImagePath: inputImages.initPath, initImageStrength,
referenceImagePaths: inputImages.referencePaths,
});
+ const fullPrompt = buildWith(prompt);
const bin = grokPath || DEFAULT_BIN;
// No model arg — grok's image tools run on xAI's fixed image backend and
@@ -276,7 +277,7 @@ export async function generateImage({
filename, mode: IMAGE_GEN_MODE.GROK,
...(visualConditioning ? { visualConditioning } : {}),
...sentPromptRecord({ sentPrompt: fullPrompt, carried: carriedPromptAdditions({ promptAdditions }),
- added: [agentInstructionsAddition('Grok image tool instructions', fullPrompt, prompt)] }),
+ added: [agentInstructionsAddition('Grok image tool instructions', buildWith)] }),
...(effectiveRatio ? { aspectRatio: effectiveRatio } : {}),
createdAt: new Date().toISOString(),
};
diff --git a/server/services/imageGen/local.test.js b/server/services/imageGen/local.test.js
index 4a0ab44782..c359eb1d64 100644
--- a/server/services/imageGen/local.test.js
+++ b/server/services/imageGen/local.test.js
@@ -898,7 +898,14 @@ describe('imageGen local.buildSidecarMeta', () => {
...baseMetaInput,
loraFilenames: ['aria.safetensors'],
loraTriggerWords: { 'aria.safetensors': ['aria_tok', 'portrait'] },
+ promptAdditions: [{ id: 'style-1', label: 'Universe style', text: 'muted earth tones' }],
});
+ // The record of what went out (#11317): exact text, carried additions, then the weave.
+ expect(meta.sentPrompt).toBe('a red cube, aria_tok');
+ expect(meta.promptAdditions).toEqual([
+ { id: 'style-1', label: 'Universe style', text: 'muted earth tones' },
+ { id: 'lora-triggers', label: 'LoRA trigger words', text: 'aria_tok' },
+ ]);
// What the runner renders.
expect(renderPrompt).toBe('a red cube, aria_tok');
expect(addedTriggerWords).toEqual(['aria_tok']);
diff --git a/server/services/videoGen/fal.test.js b/server/services/videoGen/fal.test.js
index ee10581fe5..96ef7aa2fc 100644
--- a/server/services/videoGen/fal.test.js
+++ b/server/services/videoGen/fal.test.js
@@ -170,6 +170,9 @@ describe('videoGen/fal — generateVideo', () => {
const [entry] = await loadHistory();
// 8s (the covering length) × $0.14/s audio off.
expect(entry).toMatchObject({ modelId: 'fal:fal-ai/kling-video/v3/pro/image-to-video', duration: 8, generateAudio: false, estimatedCostUsd: 1.12 });
+ // Kling takes the negative natively, so the record shows it apart and no "Avoid:" chip (#11317).
+ expect(entry).toMatchObject({ sentPrompt: 'waves roll in', sentNegativePrompt: 'text' });
+ expect(entry.promptAdditions).toBeUndefined();
if (input === 'upload') {
await vi.waitFor(async () => {
await expect(readFile(framePath)).rejects.toMatchObject({ code: 'ENOENT' });
diff --git a/server/services/videoGen/grok.js b/server/services/videoGen/grok.js
index c88b44a6b8..8aa9593f30 100644
--- a/server/services/videoGen/grok.js
+++ b/server/services/videoGen/grok.js
@@ -155,10 +155,11 @@ export async function generateVideo({
const configured = GROK_ASPECT_RATIOS.includes(aspectRatio) ? aspectRatio : null;
const effectiveRatio = derived || configured;
- const fullPrompt = buildGrokVideoPrompt({
- prompt, negativePrompt, aspectRatio: effectiveRatio, duration: effectiveDuration,
+ const buildWith = (text) => buildGrokVideoPrompt({
+ prompt: text, negativePrompt, aspectRatio: effectiveRatio, duration: effectiveDuration,
stagingPath, sourceImagePath, scratchDir,
});
+ const fullPrompt = buildWith(prompt);
const bin = grokPath || DEFAULT_BIN;
const baseArgs = ensureGrokHeadlessArgs([], null);
@@ -180,7 +181,7 @@ export async function generateVideo({
createdAt: new Date().toISOString(),
mode: sourceImagePath ? 'image' : 'text',
...sentPromptRecord({ sentPrompt: fullPrompt, carried: carriedPromptAdditions({ promptAdditions }),
- added: [agentInstructionsAddition('Grok video tool instructions', fullPrompt, prompt)] }),
+ added: [agentInstructionsAddition('Grok video tool instructions', buildWith)] }),
};
const job = { ...meta, clients: [], status: 'running', renderStartedAtMs };
jobs.set(jobId, job);