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): forge-aware handoff comment, honest fallback guideline

[._.]/ Adam Eivybf9317398020
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index 1a2d15aacc..718ef41183 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -502,7 +502,8 @@ export function buildReviewLoopFollowUpSection(metadata = {}, { verbose = false,
const closingSteps = leaveOpen
? [
'4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.',
- `5. Post a short PR comment summarising what the reviewers raised and what you fixed, so the human landing it knows the state: \`gh pr comment "${prUrl}" --body "<summary>"\`.`,
+ // Forge-aware: `gh pr comment` fails outright on a GitLab MR URL.
+ `5. Post a short comment on the ${detectForgeCli(metadata.reviewLoopPRHost) === 'glab' ? 'MR' : 'PR'} summarising what the reviewers raised and what you fixed, so the human landing it knows the state: ${detectForgeCli(metadata.reviewLoopPRHost) === 'glab' ? `\`glab mr note ${prNumber !== '' ? prNumber : '<MR_NUMBER>'} --message "<summary>"\`` : `\`gh pr comment "${prUrl}" --body "<summary>"\``}.`,
'6. Exit. Do **not** run `/do:push` or open a new PR. The system will clean up your worktree on exit.',
]
: [
@@ -701,6 +702,7 @@ function buildMergeFollowUpSection({ prUrl, prBranch, prNumber = '', prOwner = '
export function buildCompletionGuidelineBullet({
isReadOnly, isTui, tuiCompletionCommand, slashdoFree = false,
worktreeInfo, willOpenPR, willReviewLoop, discardWorktree = false, noCodeOutput = false,
+ leavePrOpen = false,
}) {
if (discardWorktree) {
return '**This is a reasoning-only task.** The worktree is discarded on exit — do NOT commit, push, merge, or open a PR. Write your result to the completion sentinel (see the Completion section) and stop.';
@@ -723,9 +725,11 @@ export function buildCompletionGuidelineBullet({
return `On successful completion, YOU run ${howTo}, then write the sentinel and stop — PortOS closes the session once it sees the sentinel; do NOT run \`/quit\`.`;
}
if (worktreeInfo && willOpenPR) {
- const reviewSuffix = willReviewLoop
- ? ' For GitHub PRs, a Copilot code review will also be requested automatically (skipped on GitLab and other non-GitHub forges) — do NOT run `/do:rpr` or attempt to address review comments yourself; you will have already exited.'
- : ' No review was requested for this task, so a follow-up agent merges the PR once CI is green — do NOT try to merge it yourself; you will have already exited.';
+ const reviewSuffix = leavePrOpen
+ ? ' This task is tracked in JIRA, so the PR is left OPEN for a human to land alongside the ticket — nothing merges it automatically.' + (willReviewLoop ? ' A follow-up agent still runs the configured reviewers against it.' : '')
+ : willReviewLoop
+ ? ' For GitHub PRs, a Copilot code review will also be requested automatically (skipped on GitLab and other non-GitHub forges) — do NOT run `/do:rpr` or attempt to address review comments yourself; you will have already exited.'
+ : ' No review was requested for this task, so a follow-up agent merges the PR once CI is green — do NOT try to merge it yourself; you will have already exited.';
return `On successful completion, the system will push your branch and open a pull request — do NOT open a PR manually. (If the task fails, no PR is opened; the worktree is then cleaned up unless a safety check preserves it for manual recovery.)${reviewSuffix}`;
}
if (worktreeInfo) {
@@ -1178,6 +1182,7 @@ ${(() => {
isReadOnly: isTruthyMetaFn(task.metadata?.readOnly),
isTui, tuiCompletionCommand, slashdoFree: isTui && isOpencodeCommand(providerCommand),
worktreeInfo, willOpenPR, willReviewLoop, discardWorktree, noCodeOutput,
+ leavePrOpen: leavesPrForHuman(task),
});
return bullet ? `- ${bullet}` : '';
})()}
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index ed07275dcd..32331f6221 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -373,6 +373,25 @@ describe('buildLightContextPrompt', () => {
expect(prompt).not.toMatch(/glab mr merge/);
});
+ it('a leave-open review follow-up on a GitLab MR comments with glab, not gh', () => {
+ const prompt = buildLightContextPrompt(
+ makeTask({ metadata: {
+ reviewLoopFollowUp: true,
+ reviewLoopLeaveOpen: true,
+ reviewLoopPRUrl: 'https://gitlab.com/g/p/-/merge_requests/5',
+ reviewLoopPRBranch: 'b',
+ reviewLoopPRNumber: 5,
+ reviewLoopPRHost: 'gitlab.com',
+ reviewLoopReviewers: ['codex'],
+ sourceTaskId: 'task-src-6',
+ }}),
+ '/r',
+ { branchName: 'b', worktreePath: '/tmp/wt' },
+ isTruthyMeta);
+ expect(prompt).toMatch(/glab mr note 5 --message/);
+ expect(prompt).not.toMatch(/gh pr comment/);
+ });
+
it('a review-loop follow-up on a JIRA PR reviews but does not merge', () => {
const prompt = buildLightContextPrompt(
makeTask({ metadata: {
@@ -1277,6 +1296,15 @@ describe('buildCompletionGuidelineBullet', () => {
worktreeInfo: { worktreePath: '/wt' }, willOpenPR: true, willReviewLoop: false,
});
expect(prBullet).toMatch(/the system will push your branch and open a pull request/);
+ // Without a review loop, a follow-up merges on green CI...
+ expect(prBullet).toMatch(/merges the PR once CI is green/);
+ // ...unless the PR is a human's to land, where the bullet must not promise a merge.
+ const jiraBullet = buildCompletionGuidelineBullet({
+ isReadOnly: false, isTui: false, tuiCompletionCommand: '/do:pr',
+ worktreeInfo: { worktreePath: '/wt' }, willOpenPR: true, willReviewLoop: false, leavePrOpen: true,
+ });
+ expect(jiraBullet).toMatch(/left OPEN for a human/);
+ expect(jiraBullet).not.toMatch(/merges the PR once CI is green/);
// No worktree, not TUI, not read-only → no bullet.
const none = buildCompletionGuidelineBullet({
isReadOnly: false, isTui: false, tuiCompletionCommand: '/do:push',