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
prompt: emit the issue-filing contract once when the task body already embeds it
[._.]/ Adam Eivy36473cf34e54
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 5cf70421d9..d19f157918 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -129,6 +129,14 @@ function resolveSentinelPath(worktreeInfo, workspaceDir, agentId) {const PREVIOUS_STAGE_OUTPUT_INLINE_CAP = 12_000;+/**+ * The task body as the agent reads it — description plus prompt/context block —+ * so a contract section can skip text the task already carries verbatim.+ */+function renderedTaskText(task) {+ return [task.description, taskContextBlock(task)].filter(Boolean).join('\n');+}+function pipelineContextLines(pipelineCtx) {if (!pipelineCtx || (!pipelineCtx.previousStageAgentId && !pipelineCtx.previousStageOutput)) return [];@@ -414,7 +422,7 @@ export async function buildAgentPrompt(task, config, workspaceDir, worktreeInfo// flag spelling, which the guidance spells out for whichever the agent has.const issueFilingSection = skipDevContext? ''- : buildIssueFilingSection({ providerId, model: providerModel });+ : buildIssueFilingSection({ providerId, model: providerModel, taskText: renderedTaskText(task) });// Architect doctrine for an orchestrated run (#5992). '' for every direct-mode// task, which is the default, so this is inert unless a profile is configured.const orchestrationSection = buildOrchestrationDoctrineSection(task);@@ -1098,7 +1106,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet// Unconditional filing rules, with planner attribution when resolvable:// whether a run ends up filing an issue is not knowable from its metadata,// and a model cannot name itself.- const lightFilingSection = buildIssueFilingSection({ providerId, model: providerModel, forgeCli: resolvedForgeCli });+ const lightFilingSection = buildIssueFilingSection({ providerId, model: providerModel, forgeCli: resolvedForgeCli, taskText: renderedTaskText(task) });if (lightFilingSection) contractSections.push(lightFilingSection);// --- Orchestrated execution ---------------------------------------------diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 872f6a26ec..159b0ec7a6 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -4277,6 +4277,45 @@ describe('planner attribution', () => {expect(text).toMatch(/--label planner:opus-5/);});+ // The shipped claim-issue / issue-reconcile prompts open with the same+ // contract. Rendering it again as a contract section made every such run+ // read ~3KB twice; the attribution still has to come from PortOS because the+ // task body cannot name the model it was dispatched with.+ it('emits only the planner attribution when the task body already carries the contract verbatim', () => {+ const task = makeTask({+ description: `[Claim Issue] Ship the next issue\n\n${MANDATORY_DISPATCH_HINT_GUIDANCE}\n\n## Phase 1`,+ metadata: { openPR: false },+ });+ const prompt = buildLightContextPrompt(task, '/repo', null, isTruthyMeta,+ { providerId: 'claude-code-tui', providerCommand: 'claude', providerModel: 'claude-opus-5' });+ expect(prompt.split(MANDATORY_DISPATCH_HINT_GUIDANCE).length - 1).toBe(1);+ expect(prompt).not.toContain('## Issue Filing Labels');+ expect(prompt).toMatch(/## Planner Attribution/);+ expect(prompt).toMatch(/--label planner:opus-5/);+ });++ it('dedupes the contract on the api path too', async () => {+ const task = makeTask({+ description: `[Claim Issue] Ship the next issue\n\n${MANDATORY_DISPATCH_HINT_GUIDANCE}\n\n## Phase 1`,+ metadata: { openPR: false },+ });+ const prompt = await buildAgentPrompt(task, {}, '/repo', null, isTruthyMeta,+ { providerType: 'api', providerId: 'lmstudio', providerModel: 'claude-opus-5' });+ const text = typeof prompt === 'string' ? prompt : prompt.userPrompt;+ expect(text.split(MANDATORY_DISPATCH_HINT_GUIDANCE).length - 1).toBe(1);+ expect(text).not.toContain('## Issue Filing Labels');+ expect(text).toMatch(/--label planner:opus-5/);+ });++ it('keeps the full contract for a task that paraphrased it', () => {+ const prompt = buildLightContextPrompt(+ makeTask({ description: 'File issues with model: and effort: labels.', metadata: { openPR: false } }),+ '/repo', null, isTruthyMeta, { providerId: 'claude-code-tui', providerCommand: 'claude' },+ );+ expect(prompt).toContain('## Issue Filing Labels');+ expect(prompt.split(MANDATORY_DISPATCH_HINT_GUIDANCE).length - 1).toBe(1);+ });+it('still enforces filing labels when PortOS cannot attribute the run', () => {const prompt = buildLightContextPrompt(makeTask({ metadata: { openPR: false } }), '/repo', null, isTruthyMeta, {},diff --git a/server/services/promptSections/plannerAttribution.js b/server/services/promptSections/plannerAttribution.jsindex adcdd0db80..88879279b6 100644--- a/server/services/promptSections/plannerAttribution.js+++ b/server/services/promptSections/plannerAttribution.js@@ -35,8 +35,23 @@ export function buildPlannerAttributionSection({ providerId = null, model = nullreturn `## Planner Attribution\n\n${guidance}`;}-/** Runtime contract reaches stored/custom tasks and follow-ups, even without a planner identity. */-export function buildIssueFilingSection(options = {}) {+/**+ * Runtime contract reaches stored/custom tasks and follow-ups, even without a+ * planner identity.+ *+ * `taskText` is the task body the agent is about to read (description plus+ * context). The shipped claim-issue / issue-reconcile prompts embed the very+ * same contract at their top, so a run built from one of them would otherwise+ * read the ~3KB block twice — once in the task, once here. When the body+ * already carries it verbatim, only the planner attribution (which the task+ * cannot know about itself) is emitted; a customized prompt that dropped or+ * paraphrased the contract still gets the full section.+ *+ * @param {object} [options]+ * @param {string} [options.taskText] - rendered task body to dedupe against+ */+export function buildIssueFilingSection({ taskText = '', ...options } = {}) {const attribution = buildPlannerAttributionSection(options);+ if (taskText.includes(MANDATORY_DISPATCH_HINT_GUIDANCE)) return attribution;return `## Issue Filing Labels\n\n${MANDATORY_DISPATCH_HINT_GUIDANCE}${attribution ? `\n\n${attribution}` : ''}`;}