Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
refactor(daemon): retire the generic no-reply rule — ordinary agents always post one comment (MUL-5442) (#6493)
Bohan Jiangd6d199621070
diff --git a/server/internal/daemon/daemon_test.go b/server/internal/daemon/daemon_test.goindex be34e46aed..314851c038 100644--- a/server/internal/daemon/daemon_test.go+++ b/server/internal/daemon/daemon_test.go@@ -1042,11 +1042,10 @@ func TestBuildPromptCommentTriggered(t *testing.T) {commentID,"multica issue comment add " + issueID + " --parent " + commentID,"do NOT reuse --parent values from previous turns",- // Silence-as-valid-exit for agent-to-agent loops depends on the- // reply command being framed conditionally rather than as a hard- // requirement. Guard the phrasing so the conflict with the new- // workflow (MUL-1323) doesn't come back.- "If you decide to reply",+ // MUL-5442 (2026-08-06): with the generic no-reply rule retired,+ // the reply command is framed as a plain imperative again — the+ // squad leader's `no_action` block states its own exception.+ "Post your reply as a comment",} {if !strings.Contains(prompt, want) {t.Fatalf("prompt missing %q\n---\n%s", want, prompt)@@ -1059,11 +1058,17 @@ func TestBuildPromptCommentTriggered(t *testing.T) {}}-// TestBuildPromptCommentTriggeredByAgent covers the agent-to-agent mention-// loop signal injected into the per-turn prompt (MUL-1323 / GH#1576). When-// the triggering comment was posted by another agent, the prompt must name-// the author, warn against sign-off @mentions, and point at silence as a-// valid exit.+// TestBuildPromptCommentTriggeredByAgent covers the trigger-attribution+// line for agent-authored triggers, and guards the RETIREMENT of the+// generic no-reply warning block that used to follow it (MUL-1323 /+// GH#1576). Retired by MUL-5442 owner decision (2026-08-06): an agent+// comment cannot wake an ordinary agent without an explicit @mention+// (computeCommentAgentTriggers routes agent-authored comments only via+// mentions, plus the squad-leader wake), so loop prevention belongs to the+// mention discipline in the brief's `## Mentions`, and recorded silence+// stays squad-leader-only (`no_action`). Retired pins, now negative+// guards: "do not @mention the other agent as a sign-off", "Silence is+// the preferred way".func TestBuildPromptCommentTriggeredByAgent(t *testing.T) {t.Parallel()@@ -1076,13 +1081,20 @@ func TestBuildPromptCommentTriggeredByAgent(t *testing.T) {Agent: &AgentData{Name: "Test"},}, "claude")- for _, want := range []string{- "Another agent (Atlas)",- "do not @mention the other agent as a sign-off",+ if !strings.Contains(prompt, "Another agent (Atlas)") {+ t.Fatalf("prompt missing trigger attribution\n---\n%s", prompt)+ }+ for _, banned := range []string{"Silence is the preferred way",+ "do not @mention the other agent as a sign-off",+ "reply is warranted",+ "exit with no output",+ // The conditional reply framing was the door the retired rule+ // walked through — guard it shut (MUL-5442 #6493 review).+ "If you decide to reply",} {- if !strings.Contains(prompt, want) {- t.Fatalf("prompt missing %q\n---\n%s", want, prompt)+ if strings.Contains(prompt, banned) {+ t.Fatalf("per-turn prompt still carries retired no-reply warning %q\n---\n%s", banned, prompt)}}}@@ -1108,15 +1120,16 @@ func TestBuildPromptCommentTriggeredByMember(t *testing.T) {if strings.Contains(prompt, "Another agent") {t.Fatalf("member-triggered prompt should not claim the author was another agent")}- // Must NOT use the old "You MUST respond" language — that conflicts with- // the agent-to-agent silence-as-valid-exit workflow. Even on human-authored- // triggers, the reply command is framed conditionally for a single- // consistent rule across turn types.+ // Must NOT use the old "You MUST respond" language: the reply command is+ // shared across turn types, and a squad leader's `no_action` exit — the+ // one silent path left after MUL-5442 retired the generic no-reply rule —+ // must not be shouted over by the per-turn channel. The unconditional+ // one-comment contract for ordinary agents lives in the brief.if strings.Contains(prompt, "MUST respond") {t.Fatalf("prompt should not contain unconditional \"MUST respond\" language\n---\n%s", prompt)}- if !strings.Contains(prompt, "If you decide to reply") {- t.Fatalf("prompt should frame the reply command conditionally\n---\n%s", prompt)+ if !strings.Contains(prompt, "Post your reply as a comment") {+ t.Fatalf("prompt should carry the imperative reply command\n---\n%s", prompt)}}@@ -5013,3 +5026,95 @@ func TestFreshSessionMayHelp(t *testing.T) {t.Fatalf("freshSessionMayHelp(auth-resolution error) = false; a fresh session cures this failure, it must report session-fixable")}}++// TestBuildPromptSquadLeaderReplyCommandCarvesOutNoAction renders the COMPLETE+// leader prompt and pins the exception's scope relation (MUL-5442 #6493+// review): the no_action rule and the reply imperative appear in the same+// prompt, so the imperative must carry the carve-out itself — a bare+// unconditional "Post your reply as a comment" anywhere in a leader prompt+// re-opens the contradiction the carve-out exists to close.+func TestBuildPromptSquadLeaderReplyCommandCarvesOutNoAction(t *testing.T) {+ t.Parallel()++ prompt := BuildPrompt(Task{+ IssueID: "issue-1",+ TriggerCommentID: "comment-1",+ TriggerCommentContent: "team update posted",+ TriggerAuthorType: "member",+ TriggerAuthorName: "Bohan",+ Agent: &AgentData{+ Name: "Lead",+ Instructions: "Some instructions\n\n## Squad Operating Protocol\n\nYou are the LEADER...",+ },+ }, "claude")++ if !strings.Contains(prompt, "Squad leader no_action rule") {+ t.Fatalf("leader prompt missing the no_action rule\n---\n%s", prompt)+ }+ if !strings.Contains(prompt, "Unless your outcome is `no_action`, post your reply as a comment") {+ t.Fatalf("leader prompt missing the carve-out reply imperative\n---\n%s", prompt)+ }+ if strings.Contains(prompt, "Post your reply as a comment") {+ t.Fatalf("leader prompt still carries the unconditional reply imperative\n---\n%s", prompt)+ }+}++// TestBuildPromptSquadLeaderMultiThreadCarvesOutNoAction renders the complete+// leader prompt on the cross-thread fan-out path (MUL-5442 #6493 review): the+// fan-out imperative fires AFTER the no_action rule, so its scope sentence+// must govern the ENTIRE block — assert it precedes every later obligation,+// not just the first verb. The ordinary fan-out output keeps the+// unconditional form byte-for-byte.+func TestBuildPromptSquadLeaderMultiThreadCarvesOutNoAction(t *testing.T) {+ t.Parallel()++ leaderTask := Task{+ IssueID: "issue-1",+ TriggerCommentID: "comment-9",+ TriggerThreadID: "thread-B",+ TriggerCommentContent: "second update",+ TriggerAuthorType: "agent",+ TriggerAuthorName: "Worker",+ CoalescedComments: []CoalescedCommentData{+ {ID: "comment-8", ThreadID: "thread-A", Content: "first update"},+ },+ Agent: &AgentData{+ Name: "Lead",+ Instructions: "Some instructions\n\n## Squad Operating Protocol\n\nYou are the LEADER...",+ },+ }+ prompt := BuildPrompt(leaderTask, "claude")+ if !strings.Contains(prompt, "Squad leader no_action rule") {+ t.Fatalf("leader multi-thread prompt missing the no_action rule\n---\n%s", prompt)+ }+ scope := strings.Index(prompt, "skip this ENTIRE fan-out block")+ if scope < 0 {+ t.Fatalf("leader multi-thread prompt missing the whole-block scope sentence\n---\n%s", prompt)+ }+ for _, obligation := range []string{+ "multiple replies are required and correct",+ "Post the replies in the order listed below",+ "For EACH thread above",+ } {+ idx := strings.Index(prompt, obligation)+ if idx < 0 {+ t.Fatalf("leader multi-thread prompt missing obligation %q\n---\n%s", obligation, prompt)+ }+ if idx < scope {+ t.Fatalf("obligation %q precedes the no_action scope sentence — it escapes the carve-out\n---\n%s", obligation, prompt)+ }+ }+ if strings.Contains(prompt, ". Post ONE reply per thread") {+ t.Fatalf("leader multi-thread prompt still carries the unconditional imperative\n---\n%s", prompt)+ }++ ordinaryTask := leaderTask+ ordinaryTask.Agent = &AgentData{Name: "Reg", Instructions: "You are a regular agent."}+ ordinary := BuildPrompt(ordinaryTask, "claude")+ if !strings.Contains(ordinary, ". Post ONE reply per thread") {+ t.Fatalf("ordinary multi-thread prompt missing the unconditional imperative\n---\n%s", ordinary)+ }+ if strings.Contains(ordinary, "Unless your outcome is") || strings.Contains(ordinary, "skip this ENTIRE fan-out block") {+ t.Fatalf("ordinary multi-thread prompt leaked the leader carve-out\n---\n%s", ordinary)+ }+}diff --git a/server/internal/daemon/execenv/execenv_test.go b/server/internal/daemon/execenv/execenv_test.goindex 6e6a5bfb31..14b065aff3 100644--- a/server/internal/daemon/execenv/execenv_test.go+++ b/server/internal/daemon/execenv/execenv_test.go@@ -4995,28 +4995,48 @@ func TestInjectRuntimeConfigMentionLoopHardening(t *testing.T) {}})- t.Run("workflow-carries-silence-as-exit-and-no-signoff-mention", func(t *testing.T) {+ t.Run("workflow-reply-is-unconditional-and-no-signoff-mention", func(t *testing.T) {t.Parallel()s := readClaudeMD(t, commentTriggerCtx)- // The anti-loop signal must reach the brief; lock in the key phrases so- // it can't decay back into pure prose again. The reply-warranted rules- // live in the Reply mode block, while the no-sign-off-mention rule is- // mention policy and lives in `## Mentions` (MUL-5442) — these- // assertions are file-wide on purpose, so the signal is pinned without- // pinning which section carries it.+ // MUL-5442 owner decision (2026-08-06): the generic no-reply rule is+ // retired. It never carried the loop prevention — agent comments+ // trigger nothing without an explicit @mention (the sole implicit+ // wake is the squad-leader path), so the mention discipline pinned in+ // the Mentions subtest above is the real defense. Ordinary agents are+ // back on the unconditional one-comment-per-run contract; recorded+ // silence via `no_action` remains squad-leader-only. Retired pins,+ // replaced by the negative guards below so the apparatus cannot creep+ // back: "Decide whether a reply is warranted", "produced actual+ // work", "pure acknowledgment / thanks / sign-off", "do NOT reply",+ // "Silence is a valid and preferred way".for _, want := range []string{+ "Posting your reply as a comment is mandatory",+ "Do any requested work first",+ "Never @mention the agent you are replying to as a thank-you or sign-off",+ } {+ if !strings.Contains(s, want) {+ t.Errorf("comment-triggered CLAUDE.md missing %q", want)+ }+ }+ for _, banned := range []string{"Decide whether a reply is warranted",- // Both outcomes pinned individually (MUL-5442 stage-1 review):- // the work-produced arm and the silent-exit arm must each- // survive compression, not just the bullet's heading.+ "exit with no output",+ "Silence is a valid and preferred way",+ "conditional on the reply rule",+ // #6493 review: the ledger named five retired pins but only+ // guarded two — the missing three let the old apparatus+ // coexist with the new sentences. Ordinary-agent scope only:+ // the leader's no_action bullet says "DO NOT post any+ // comment", which none of these match."produced actual work","pure acknowledgment / thanks / sign-off","do NOT reply",- "Silence is a valid and preferred way",- "Never @mention the agent you are replying to as a thank-you or sign-off",+ // Leader-leak guard: the carve-out imperative is+ // leader-brief-only.+ "Unless your outcome is",} {- if !strings.Contains(s, want) {- t.Errorf("comment-triggered CLAUDE.md missing %q", want)+ if strings.Contains(s, banned) {+ t.Errorf("comment-triggered CLAUDE.md still carries retired no-reply text %q", banned)}}})@@ -5045,16 +5065,25 @@ func TestInjectRuntimeConfigSquadLeaderCommentTriggeredNoAction(t *testing.T) {}s := string(data)- // The comment-triggered workflow must contain the squad leader no_action rule.+ // The comment-triggered workflow must contain the squad leader no_action+ // rule, and the reply imperative must carry the no_action carve-out so a+ // later bullet never contradicts it (MUL-5442 #6493 review).for _, want := range []string{"Squad leader rule","DO NOT post any comment","multica squad activity",+ "Unless your outcome is `no_action` (Squad leader rule above), posting your reply as a comment is mandatory",} {if !strings.Contains(s, want) {t.Errorf("squad leader comment-triggered CLAUDE.md missing %q", want)}}+ // Capital-P form = the ordinary unconditional bullet; the leader brief+ // must carry only the carve-out variant (its lowercase "posting your+ // reply as a comment is mandatory" tail is expected and legal).+ if strings.Contains(s, "Posting your reply as a comment is mandatory") {+ t.Errorf("squad leader CLAUDE.md still carries the unconditional reply bullet")+ }// The Output section must use strong prohibition language.if !strings.Contains(s, "you MUST exit without posting any comment") {diff --git a/server/internal/daemon/execenv/git.go b/server/internal/daemon/execenv/git.goindex 3364a4dcc6..456b497a92 100644--- a/server/internal/daemon/execenv/git.go+++ b/server/internal/daemon/execenv/git.go@@ -9,7 +9,6 @@ import ("regexp""strings""time"-)// detectGitRepo checks if dir is inside a git repository (regular or bare).@@ -111,7 +110,7 @@ func removeGitWorktree(gitRoot, worktreePath, branchName string, logger *slog.Lo// Delete the branch (best-effort).if branchName != "" {cmd = exec.Command("git", "-C", gitRoot, "branch", "-D", branchName)-+if out, err := cmd.CombinedOutput(); err != nil {logger.Warn("execenv: git branch delete failed", "branch", branchName, "output", strings.TrimSpace(string(out)), "error", err)}diff --git a/server/internal/daemon/execenv/reply_instructions.go b/server/internal/daemon/execenv/reply_instructions.goindex cf382974c8..7510bbea88 100644--- a/server/internal/daemon/execenv/reply_instructions.go+++ b/server/internal/daemon/execenv/reply_instructions.go@@ -162,11 +162,11 @@ func activeThreadID(triggerThreadID, triggerCommentID string) string {//// provider is retained for caller symmetry and future per-provider tweaks; the// guardrail itself is intentionally identical across providers and hosts.-func BuildCommentReplyInstructions(provider, issueID, triggerCommentID string) string {+func BuildCommentReplyInstructions(provider, issueID, triggerCommentID string, squadLeader bool) string {if triggerCommentID == "" {return ""}- return buildCommentReplyInstructionsSlim(provider, issueID, triggerCommentID)+ return buildCommentReplyInstructionsSlim(provider, issueID, triggerCommentID, squadLeader)}// buildCommentReplyInstructionsSlim is the compressed reply-instructions@@ -182,10 +182,18 @@ func BuildCommentReplyInstructions(provider, issueID, triggerCommentID string) s// canonical `## Comment Formatting` section the same brief carries, so// repeating it inline at every comment-triggered step 7 would be// duplication, not signal.-func buildCommentReplyInstructionsSlim(provider, issueID, triggerCommentID string) string {+func buildCommentReplyInstructionsSlim(provider, issueID, triggerCommentID string, squadLeader bool) string {+ // The squad leader's `no_action` exit (recorded via `squad activity`) is+ // the one path where posting no comment is correct — the imperative must+ // carry its own carve-out so a later line never contradicts the+ // no_action rule injected above it (MUL-5442 #6493 review).+ lead := "Post your reply as a comment — always use the trigger comment ID below, "+ if squadLeader {+ lead = "Unless your outcome is `no_action`, post your reply as a comment — always use the trigger comment ID below, "+ }if runtimeGOOS == "windows" {return fmt.Sprintf(- "If you decide to reply, post it as a comment — always use the trigger comment ID below, "++ lead+"do NOT reuse --parent values from previous turns in this session.\n\n"+"Write the body file first — never pipe via `--content-stdin` (PowerShell drops non-ASCII; full rules: ## Comment Formatting above):\n\n"+" multica issue comment add %s --parent %s --content-file ./reply.md\n"+@@ -195,7 +203,7 @@ func buildCommentReplyInstructionsSlim(provider, issueID, triggerCommentID strin)}return fmt.Sprintf(- "If you decide to reply, post it as a comment — always use the trigger comment ID below, "++ lead+"do NOT reuse --parent values from previous turns in this session.\n\n"+"Write the body file first (rules: ## Comment Formatting above — MUL-2904 / #4182):\n\n"+" multica issue comment add %s --parent %s --content-file ./reply.md\n"+@@ -228,7 +236,7 @@ type ThreadReplyTarget struct {// before this instruction is emitted, so a per-thread fan-out cannot split it.//// Returns "" for fewer than two targets; callers keep the single-parent path.-func BuildMultiThreadCommentReplyInstructions(issueID string, targets []ThreadReplyTarget) string {+func BuildMultiThreadCommentReplyInstructions(issueID string, targets []ThreadReplyTarget, squadLeader bool) string {if issueID == "" || len(targets) < 2 {return ""}@@ -262,8 +270,19 @@ func BuildMultiThreadCommentReplyInstructions(issueID string, targets []ThreadRe)}+ // Same carve-out as the single-thread cookbook (MUL-5442 #6493 review):+ // the leader's no_action exit must not be contradicted by this later+ // imperative, and the scope sentence must govern the ENTIRE fan-out+ // block — every obligation below ("multiple replies are required", the+ // posting order, the per-thread cookbook) sits under the "Otherwise" —+ // not just the first verb. Ordinary agents keep the unconditional form+ // byte-for-byte.+ lead := "This run coalesced comments from %d DISTINCT threads. Post ONE reply per thread"+ if squadLeader {+ lead = "This run coalesced comments from %d DISTINCT threads. **If your outcome is `no_action`, skip this ENTIRE fan-out block — post no replies at all and exit via `multica squad activity` as your leader rules direct; everything below applies only otherwise.** Otherwise, post ONE reply per thread"+ }return fmt.Sprintf(- "This run coalesced comments from %d DISTINCT threads. Post ONE reply per thread — %d replies in total — each threaded under its own conversation. This OVERRIDES the general \"post exactly one comment per run\" guidance: for THIS run multiple replies are required and correct. Do NOT merge separate threads into a single comment, and do NOT post more than one reply in the same thread.\n\n"++ lead+" — %d replies in total — each threaded under its own conversation. This OVERRIDES the general \"post exactly one comment per run\" guidance: for THIS run multiple replies are required and correct. Do NOT merge separate threads into a single comment, and do NOT post more than one reply in the same thread.\n\n"+"Post the replies in the order listed below — OLDEST thread first, the newest (triggering) thread LAST — so they land in chronological order. Do NOT answer the newest/triggering comment first.\n\n"+"Reply targets, in the order to post them (use the exact `--parent` for each — do NOT reuse `--parent` values from previous turns in this session):\n"+"%s\n"+diff --git a/server/internal/daemon/execenv/reply_instructions_test.go b/server/internal/daemon/execenv/reply_instructions_test.goindex b585b890fb..8c9ee47b93 100644--- a/server/internal/daemon/execenv/reply_instructions_test.go+++ b/server/internal/daemon/execenv/reply_instructions_test.go@@ -26,7 +26,7 @@ func TestBuildCommentReplyInstructionsCodexLinux(t *testing.T) {issueID := "11111111-1111-1111-1111-111111111111"triggerID := "22222222-2222-2222-2222-222222222222"- got := BuildCommentReplyInstructions("codex", issueID, triggerID)+ got := BuildCommentReplyInstructions("codex", issueID, triggerID, false)for _, want := range []string{"multica issue comment add " + issueID + " --parent " + triggerID + " --content-file ./reply.md",@@ -82,7 +82,7 @@ func TestBuildCommentReplyInstructionsNonCodexLinux(t *testing.T) {name := provider + "/" + hostt.Run(name, func(t *testing.T) {runtimeGOOS = host- got := BuildCommentReplyInstructions(provider, issueID, triggerID)+ got := BuildCommentReplyInstructions(provider, issueID, triggerID, false)for _, want := range []string{"multica issue comment add " + issueID + " --parent " + triggerID + " --content-file ./reply.md",@@ -94,7 +94,7 @@ func TestBuildCommentReplyInstructionsNonCodexLinux(t *testing.T) {"#4182","rm ./reply.md","do NOT reuse --parent values from previous turns",- "If you decide to reply",+ "Post your reply as a comment",} {if !strings.Contains(got, want) {t.Errorf("%s reply instructions missing %q\n---\n%s", name, want, got)@@ -138,7 +138,7 @@ func TestBuildCommentReplyInstructionsWindowsUsesContentFile(t *testing.T) {for _, provider := range []string{"codex", "claude", "opencode", "openclaw", "hermes", "kimi", "reasonix", "kiro", "cursor"} {t.Run(provider+"/windows", func(t *testing.T) {- got := BuildCommentReplyInstructions(provider, issueID, triggerID)+ got := BuildCommentReplyInstructions(provider, issueID, triggerID, false)for _, want := range []string{"multica issue comment add " + issueID + " --parent " + triggerID + " --content-file",// MUL-5442 cross-channel dedup: the $OutputEncoding trap's@@ -171,7 +171,7 @@ func TestBuildCommentReplyInstructionsEmptyWhenNoTrigger(t *testing.T) {t.Parallel()for _, provider := range []string{"codex", "claude", "opencode"} {- if got := BuildCommentReplyInstructions(provider, "issue-id", ""); got != "" {+ if got := BuildCommentReplyInstructions(provider, "issue-id", "", false); got != "" {t.Fatalf("expected empty string when triggerCommentID is empty for %s, got %q", provider, got)}}@@ -240,7 +240,7 @@ func TestWindowsCommentReplyInstructionsHaveNoStdin(t *testing.T) {for _, provider := range []string{"claude", "codex", "opencode"} {t.Run(provider, func(t *testing.T) {- s := BuildCommentReplyInstructions(provider, issueID, triggerID)+ s := BuildCommentReplyInstructions(provider, issueID, triggerID, false)for _, want := range []string{"multica issue comment add " + issueID + " --parent " + triggerID + " --content-file","--content-file",@@ -322,3 +322,28 @@ func TestInjectRuntimeConfigWindowsAssignmentBriefStaysFileOnly(t *testing.T) {})}}++// TestBuildCommentReplyInstructionsSquadLeaderCarveOut pins that the squad+// leader variant scopes the reply imperative with the `no_action` exception+// (MUL-5442 #6493 review): the leader's only silent path must not be+// contradicted by a later unconditional "Post your reply" line, and the+// ordinary variant must never carry the leader carve-out.+func TestBuildCommentReplyInstructionsSquadLeaderCarveOut(t *testing.T) {+ t.Parallel()++ leader := BuildCommentReplyInstructions("claude", "issue-1", "comment-1", true)+ if !strings.Contains(leader, "Unless your outcome is `no_action`, post your reply as a comment") {+ t.Errorf("leader reply instructions missing the no_action carve-out\n---\n%s", leader)+ }+ if strings.Contains(leader, "Post your reply as a comment") {+ t.Errorf("leader reply instructions still carry the unconditional imperative\n---\n%s", leader)+ }++ ordinary := BuildCommentReplyInstructions("claude", "issue-1", "comment-1", false)+ if !strings.Contains(ordinary, "Post your reply as a comment") {+ t.Errorf("ordinary reply instructions missing the imperative\n---\n%s", ordinary)+ }+ if strings.Contains(ordinary, "Unless your outcome is") {+ t.Errorf("ordinary reply instructions leaked the leader carve-out\n---\n%s", ordinary)+ }+}diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.goindex c05a4a07af..916d7d3f8f 100644--- a/server/internal/daemon/execenv/runtime_config_sections.go+++ b/server/internal/daemon/execenv/runtime_config_sections.go@@ -551,7 +551,7 @@ func writeWorkflowIssue(b *strings.Builder, ctx TaskContextForEnv) {if ctx.IsSquadLeader {b.WriteString("5. **Post your final results as a comment** (unless your outcome is `no_action` — in that case, calling `multica squad activity <issue-id> no_action --reason \"...\"` alone is sufficient; you MUST exit without posting any comment. DO NOT post a comment announcing no_action or saying you are exiting silently): post it with `multica issue comment add` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). Your results are only visible to the user if posted via this CLI call; text in your terminal or run logs is NOT delivered.\n")} else {- b.WriteString("5. **Post your final results as a comment — this step is mandatory**: post it with `multica issue comment add` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). `## Output` states why this call is the only delivery channel. In Reply mode this step is conditional on the reply rule below.\n")+ b.WriteString("5. **Post your final results as a comment — this step is mandatory**: post it with `multica issue comment add` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). `## Output` states why this call is the only delivery channel.\n")}b.WriteString("6. Before exiting, pin or clear a metadata key via `multica issue metadata set`/`delete` only if it clears the bar in `## Issue Metadata`. Most runs write nothing here — that is the expected outcome, not a gap. When in doubt, do not write.\n\n")@@ -566,12 +566,15 @@ func writeWorkflowIssue(b *strings.Builder, ctx TaskContextForEnv) {b.WriteString("**Reply mode only — respond to the comment in the user message**\n\n")b.WriteString("- Respond to THAT specific comment; take its id from the user message, never from this file or from an earlier turn.\n")- b.WriteString("- **Decide whether a reply is warranted.** If you produced actual work this turn, post the result via step 5. If the triggering comment was a pure acknowledgment / thanks / sign-off from another agent AND you produced no work, do NOT reply — not even a 'No reply needed' comment; exit with no output. Silence is a valid and preferred way to end agent-to-agent conversations.\n")if ctx.IsSquadLeader {b.WriteString("- **Squad leader rule:** If your evaluation outcome is `no_action`, call `multica squad activity <issue-id> no_action --reason \"...\"` and then EXIT IMMEDIATELY. DO NOT post any comment whose only purpose is to announce that you are taking no action, exiting silently, or acknowledging another agent. A comment like \"No action needed\" or \"Exiting silently\" is noise — the `squad activity` call already records your decision in the timeline.\n")}- b.WriteString("- If a reply IS warranted: do any requested work first, then **decide whether to include any `@mention` link.** The default is NO mention; `## Mentions` states when one is warranted.\n")- b.WriteString("- **If you reply, posting it as a comment is mandatory** (`## Output`). Use the `--parent` value the per-turn user message gives you for this turn; do NOT reuse a `--parent` from an earlier turn in this session. When that message lists more than one thread to answer, post one reply per thread instead of merging them.\n")+ b.WriteString("- Do any requested work first, then **decide whether to include any `@mention` link.** The default is NO mention; `## Mentions` states when one is warranted.\n")+ if ctx.IsSquadLeader {+ b.WriteString("- **Unless your outcome is `no_action` (Squad leader rule above), posting your reply as a comment is mandatory** (`## Output`). Use the `--parent` value the per-turn user message gives you for this turn; do NOT reuse a `--parent` from an earlier turn in this session. When that message lists more than one thread to answer, post one reply per thread instead of merging them.\n")+ } else {+ b.WriteString("- **Posting your reply as a comment is mandatory** (`## Output`). Use the `--parent` value the per-turn user message gives you for this turn; do NOT reuse a `--parent` from an earlier turn in this session. When that message lists more than one thread to answer, post one reply per thread instead of merging them.\n")+ }if ctx.IsSquadLeader {// The default rule below and the Squad Operating Protocol's// "Own the parent issue status" responsibility would otherwisediff --git a/server/internal/daemon/execenv/runtime_config_test.go b/server/internal/daemon/execenv/runtime_config_test.goindex 866668c9f7..0cc254347b 100644--- a/server/internal/daemon/execenv/runtime_config_test.go+++ b/server/internal/daemon/execenv/runtime_config_test.go@@ -1549,7 +1549,7 @@ func TestMultiThreadReplyInstructionsFanOut(t *testing.T) {{ThreadID: "c1", ParentID: "c1"},{ThreadID: "c2", ParentID: "c2"},{ThreadID: "c3", ParentID: "c3"},- })+ }, false)for _, want := range []string{"3 DISTINCT threads", "Post ONE reply per thread", "--parent c1", "--parent c2", "--parent c3"} {if !strings.Contains(out, want) {@@ -1561,7 +1561,7 @@ func TestMultiThreadReplyInstructionsFanOut(t *testing.T) {// Single-thread reply cookbook moved to the per-turn prompt (MUL-5377).func TestSingleThreadReplyInstructionsKeepSingleParent(t *testing.T) {t.Parallel()- out := BuildCommentReplyInstructions("claude", "55555555-6666-7777-8888-999999999999", "c3")+ out := BuildCommentReplyInstructions("claude", "55555555-6666-7777-8888-999999999999", "c3", false)if strings.Contains(out, "DISTINCT threads") {t.Errorf("single/same-thread instructions must not emit the multi-thread fan-out block, got:\n%s", out)diff --git a/server/internal/daemon/prompt.go b/server/internal/daemon/prompt.goindex d66be42d90..f71410b631 100644--- a/server/internal/daemon/prompt.go+++ b/server/internal/daemon/prompt.go@@ -330,10 +330,7 @@ func buildCommentPrompt(task Task, provider string) string {fmt.Fprintf(&b, "Fetch each id you still need directly: `multica issue comment list %s --thread <comment-id> --tail 30 --output json`. `--thread` accepts a reply id, not just a thread root, so you do not need to know which thread the comment lives in. If it is older than those 30 replies, page back with the `Next reply cursor` values (`--before` / `--before-id`) until it appears. Do not finish this turn until every id above is accounted for.\n\n",task.IssueID)}- if task.TriggerAuthorType == "agent" {- b.WriteString("⚠️ The triggering comment was posted by another agent. Decide whether a reply is warranted. If you produced actual work this turn (investigated, fixed something, answered a real question), post the result as a normal reply — that is NOT a noise comment, and the standard rule that final results must be delivered via comment still applies. If the triggering comment was a pure acknowledgment, thanks, or sign-off AND you produced no work this turn, do NOT reply — and do NOT post a comment saying 'No reply needed' or similar. Simply exit with no output. Silence is the preferred way to end agent-to-agent threads. If you do reply, do not @mention the other agent as a sign-off (that re-triggers them and starts a loop).\n\n")- }- if task.Agent != nil && strings.Contains(task.Agent.Instructions, "## Squad Operating Protocol") {+ if taskIsSquadLeader(task) {fmt.Fprintf(&b, "⚠️ **Squad leader no_action rule:** If you decide no action is needed, call `multica squad activity %s no_action --reason \"...\"` and EXIT. DO NOT post any comment — not even one that says \"no action needed\" or \"exiting silently\". The squad activity call records your decision; a comment is redundant noise.\n\n", task.IssueID)}}@@ -359,9 +356,9 @@ func buildCommentPrompt(task Task, provider string) string {// group upstream, so they keep the ordinary single-parent path below and can// never be split into duplicate replies.if targets := commentReplyThreads(task); len(targets) >= 2 {- b.WriteString(execenv.BuildMultiThreadCommentReplyInstructions(task.IssueID, targets))+ b.WriteString(execenv.BuildMultiThreadCommentReplyInstructions(task.IssueID, targets, taskIsSquadLeader(task)))} else {- b.WriteString(execenv.BuildCommentReplyInstructions(provider, task.IssueID, task.TriggerCommentID))+ b.WriteString(execenv.BuildCommentReplyInstructions(provider, task.IssueID, task.TriggerCommentID, taskIsSquadLeader(task)))}return b.String()}@@ -605,3 +602,14 @@ func buildAutopilotPrompt(task Task) string {// how the two surfaces drifted into conflict before (MUL-5696).return b.String()}++// taskIsSquadLeader reports whether THIS TASK runs the agent as a squad+// leader, identified (for now) by the squad briefing marker the server+// appends to Instructions on leader tasks. Leadership is a PER-TASK role —+// the same agent can be leader one turn and worker the next — so everything+// gated on this rides the per-turn channel. Making the cached brief fully+// role-independent (and replacing this marker check with an explicit role+// signal) is MUL-5811.+func taskIsSquadLeader(task Task) bool {+ return task.Agent != nil && strings.Contains(task.Agent.Instructions, "## Squad Operating Protocol")+}