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

address review (codex): don't strip task.metadata.app from the api-prompt template

[._.]/ Adam Eivy0c9ef6380d04
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index 181958ab4a..5986cff66f 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -728,15 +728,8 @@ ${task.metadata.jiraBranch ? 'Commit your changes to this branch. Do NOT switch
// predates the {{reviewLoopFollowUpSection}} placeholder; the built-in
// fallback is the source of truth for that section, and silently dropping
// it would leave the agent with no instructions and the loop would not run.
- // The template renders `### Target Application` from `task.metadata.app`. Drop
- // the app for the PortOS default so that section stays empty — the api agent
- // already runs in the PortOS directory, matching buildTaskBlock's behavior for
- // the light/fallback paths. Managed-app tasks keep the scoping line.
- const templateTask = task.metadata?.app === PORTOS_APP_ID
- ? { ...task, metadata: { ...task.metadata, app: undefined } }
- : task;
const promptData = isReviewLoopFollowUp ? null : await buildPrompt('cos-agent-briefing', {
- task: templateTask,
+ task,
config,
memorySection,
claudeMdSection,
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index cbbe274e3a..5c8b5a0576 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -56,7 +56,6 @@ tryReadFile: vi.fn().mockResolvedValue(null),
}));
import { buildLightContextPrompt, buildAgentPrompt, buildCompletionGuidelineBullet } from './agentPromptBuilder.js';
-import { buildPrompt } from './promptService.js';
import { isTruthyMeta } from './agentState.js';
function makeTask(overrides = {}) {
@@ -676,31 +675,6 @@ describe('buildAgentPrompt — provider type routing', () => {
expect(prompt).toMatch(/^## Completion$/m);
});
- // The api/full path renders "### Target Application" from the cos-agent-briefing
- // template's {{#task.metadata.app}} section, so the app is suppressed by stripping
- // it from the task handed to buildPrompt (rather than by buildTaskBlock). Assert on
- // the mocked buildPrompt's call args since the template render itself is mocked out.
- describe('api-path Target Application suppression', () => {
- const apiOpts = { providerType: 'api' };
- const wt = { branchName: 'b', worktreePath: '/tmp/wt' };
-
- it('strips the PortOS default app from the template task so its section stays empty', async () => {
- buildPrompt.mockClear();
- await buildAgentPrompt(
- makeTask({ metadata: { app: 'portos-default' } }), {}, '/r', wt, isTruthyMeta, apiOpts);
- const briefing = buildPrompt.mock.calls.find(([name]) => name === 'cos-agent-briefing');
- expect(briefing?.[1]?.task?.metadata?.app).toBeUndefined();
- });
-
- it('keeps a managed app on the template task so it scopes the work', async () => {
- buildPrompt.mockClear();
- await buildAgentPrompt(
- makeTask({ metadata: { app: 'comics' } }), {}, '/r', wt, isTruthyMeta, apiOpts);
- const briefing = buildPrompt.mock.calls.find(([name]) => name === 'cos-agent-briefing');
- expect(briefing?.[1]?.task?.metadata?.app).toBe('comics');
- });
- });
-
describe('split system/user prompt (Claude providers)', () => {
const wt = { branchName: 'cos/t/a', worktreePath: '/tmp/wt', baseBranch: 'main' };
const splitTask = () => makeTask({ metadata: { context: 'Some context', openPR: false } });