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
fix: simplify agent prompt developer context loading
[._.]/ Adam Eivy782597034cf0
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 3011ff5141..03a870d3de 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -414,21 +414,9 @@ export async function buildAgentPrompt(task, config, workspaceDir, worktreeInfo// 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);- // Fetch independent context sections in parallel- const [memorySection, agentInstructionsSection, digitalTwinSection] = await Promise.all([- skipDevContext- ? Promise.resolve(null)- : getMemorySection(task, { maxTokens: config.memory?.maxContextTokens || 2000 })- .catch(err => { console.log(`⚠️ Memory retrieval failed: ${err.message}`); return null; }),- skipDevContext- ? Promise.resolve(null)- : getAgentInstructionsContext(workspaceDir)- .catch(err => { console.log(`⚠️ Agent instructions retrieval failed: ${err.message}`); return null; }),- skipDevContext- ? Promise.resolve(null)- : getDigitalTwinForPrompt({ maxTokens: config.digitalTwin?.maxContextTokens || config.soul?.maxContextTokens || 2000, personaId: 'active' })- .catch(err => { console.log(`⚠️ Digital twin context retrieval failed: ${err.message}`); return null; })- ]);+ const { memorySection, agentInstructionsSection, digitalTwinSection } = await loadDeveloperContext(+ task, config, workspaceDir, skipDevContext,+ );// Build context compaction section if task is retrying after a context-limit failureconst compactionSection = task.metadata?.compaction?.needed ? buildCompactionSection(task) : '';@@ -687,6 +675,22 @@ ${buildResumeSection(task, worktreeInfo)}` : '';});}+/** Load independent developer context concurrently, unless this is a content-only task. */+async function loadDeveloperContext(task, config, workspaceDir, skipDevContext) {+ if (skipDevContext) {+ return { memorySection: null, agentInstructionsSection: null, digitalTwinSection: null };+ }+ const [memorySection, agentInstructionsSection, digitalTwinSection] = await Promise.all([+ getMemorySection(task, { maxTokens: config.memory?.maxContextTokens || 2000 })+ .catch(err => { console.log(`⚠️ Memory retrieval failed: ${err.message}`); return null; }),+ getAgentInstructionsContext(workspaceDir)+ .catch(err => { console.log(`⚠️ Agent instructions retrieval failed: ${err.message}`); return null; }),+ getDigitalTwinForPrompt({ maxTokens: config.digitalTwin?.maxContextTokens || config.soul?.maxContextTokens || 2000, personaId: 'active' })+ .catch(err => { console.log(`⚠️ Digital twin context retrieval failed: ${err.message}`); return null; })+ ]);+ return { memorySection, agentInstructionsSection, digitalTwinSection };+}+/*** The "## Simplify Step" section for the full (`api`) path — the* reuse/quality/efficiency self-review the agent runs before it commits.diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 03a13932b5..e4dfcfc898 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -3029,6 +3029,31 @@ describe('discardWorktree (reasoning-only) completion contract', () => {vi.mocked(getToolsSummaryForPrompt).mockResolvedValue('');});+ it('keeps API briefing instructions when optional context retrieval fails, preserving budget fallbacks', async () => {+ vi.mocked(getMemorySection).mockRejectedValueOnce(new Error('memory unavailable'));+ vi.mocked(getDigitalTwinForPrompt).mockRejectedValueOnce(new Error('twin unavailable'));+ const log = vi.spyOn(console, 'log').mockImplementation(() => {});+ try {+ await buildAgentPrompt(makeTask(), {+ memory: { maxContextTokens: 0 },+ digitalTwin: { maxContextTokens: 0 },+ soul: { maxContextTokens: 1200 },+ }, '/r', null, isTruthyMeta, { providerType: 'api' });+ const [, context] = vi.mocked(buildPrompt).mock.calls.at(-1);+ expect(context.memorySection).toBeNull();+ expect(context.digitalTwinSection).toBeNull();+ expect(context.agentInstructionsSection).toContain('Example Global Instructions');+ expect(context.claudeMdSection).toBe(context.agentInstructionsSection);+ expect(context.soulSection).toBeNull();+ expect(getMemorySection).toHaveBeenLastCalledWith(expect.anything(), { maxTokens: 2000 });+ expect(getDigitalTwinForPrompt).toHaveBeenLastCalledWith({ maxTokens: 1200, personaId: 'active' });+ expect(log).toHaveBeenCalledWith('⚠️ Memory retrieval failed: memory unavailable');+ expect(log).toHaveBeenCalledWith('⚠️ Digital twin context retrieval failed: twin unavailable');+ } finally {+ log.mockRestore();+ }+ });+it('a non-CD api task still loads memory, digital-twin, and onboard-tools sections', async () => {vi.mocked(getMemorySection).mockClear().mockResolvedValue('## Memory Context\nNONCD_MEMORY_SENTINEL');vi.mocked(getDigitalTwinForPrompt).mockClear().mockResolvedValue('## Digital Twin\nNONCD_TWIN_SENTINEL');