Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix: inject squad leader no_action rule for member-triggered comments (#2576)
LinYushen376cc8372a8d
diff --git a/server/internal/daemon/prompt.go b/server/internal/daemon/prompt.goindex 76eb9afbd7..caedd21af4 100644--- a/server/internal/daemon/prompt.go+++ b/server/internal/daemon/prompt.go@@ -128,9 +128,9 @@ func buildCommentPrompt(task Task, provider string) string {fmt.Fprintf(&b, "> %s\n\n", task.TriggerCommentContent)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") {- 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)- }+ }+ if task.Agent != nil && strings.Contains(task.Agent.Instructions, "## Squad Operating Protocol") {+ 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)}}fmt.Fprintf(&b, "Start by running `multica issue get %s --output json` to understand your task, then decide how to proceed.\n\n", task.IssueID)diff --git a/server/internal/daemon/prompt_test.go b/server/internal/daemon/prompt_test.goindex 6403152fe1..311e0d4205 100644--- a/server/internal/daemon/prompt_test.go+++ b/server/internal/daemon/prompt_test.go@@ -94,3 +94,68 @@ func TestBuildQuickCreatePromptProjectPinning(t *testing.T) {t.Errorf("buildQuickCreatePrompt without project must NOT mention --project, got:\n%s", plain)}}++// TestBuildPromptSquadLeaderNoActionForMemberTrigger verifies that the+// squad leader no_action prohibition is injected in the per-turn prompt+// regardless of whether the triggering comment was posted by an agent or+// a member. This was the root cause of the "LGTM is a pure acknowledgment+// — no reply needed. Exiting silently." noise comment: the prohibition+// only fired for agent-triggered comments, so member-triggered ones+// (like "LGTM") bypassed it.+func TestBuildPromptSquadLeaderNoActionForMemberTrigger(t *testing.T) {+ task := Task{+ IssueID: "issue-123",+ TriggerCommentID: "comment-456",+ TriggerCommentContent: "LGTM",+ TriggerAuthorType: "member",+ TriggerAuthorName: "Bohan",+ Agent: &AgentData{+ Instructions: "Some instructions\n\n## Squad Operating Protocol\n\nYou are the LEADER...",+ },+ }+ out := BuildPrompt(task, "claude")+ if !strings.Contains(out, "Squad leader no_action rule") {+ t.Errorf("buildCommentPrompt must inject squad leader no_action rule for member-triggered comments, got:\n%s", out)+ }+ if !strings.Contains(out, "DO NOT post any comment") {+ t.Errorf("buildCommentPrompt must contain DO NOT post prohibition for member-triggered squad leader, got:\n%s", out)+ }+}++// TestBuildPromptSquadLeaderNoActionForAgentTrigger verifies the rule also+// fires for agent-triggered comments (the original path that already worked).+func TestBuildPromptSquadLeaderNoActionForAgentTrigger(t *testing.T) {+ task := Task{+ IssueID: "issue-123",+ TriggerCommentID: "comment-456",+ TriggerCommentContent: "Deploy complete.",+ TriggerAuthorType: "agent",+ TriggerAuthorName: "deploy-boy",+ Agent: &AgentData{+ Instructions: "Some instructions\n\n## Squad Operating Protocol\n\nYou are the LEADER...",+ },+ }+ out := BuildPrompt(task, "claude")+ if !strings.Contains(out, "Squad leader no_action rule") {+ t.Errorf("buildCommentPrompt must inject squad leader no_action rule for agent-triggered comments, got:\n%s", out)+ }+}++// TestBuildPromptNonSquadLeaderNoRule verifies that non-squad-leader agents+// do NOT get the squad leader no_action rule injected.+func TestBuildPromptNonSquadLeaderNoRule(t *testing.T) {+ task := Task{+ IssueID: "issue-123",+ TriggerCommentID: "comment-456",+ TriggerCommentContent: "LGTM",+ TriggerAuthorType: "member",+ TriggerAuthorName: "Bohan",+ Agent: &AgentData{+ Instructions: "Some instructions without the squad marker",+ },+ }+ out := BuildPrompt(task, "claude")+ if strings.Contains(out, "Squad leader no_action rule") {+ t.Errorf("buildCommentPrompt must NOT inject squad leader no_action rule for non-squad-leader agents, got:\n%s", out)+ }+}