Compare commits

...

1 Commits

Author SHA1 Message Date
Jiang Bohan
0745bf85ab fix(squads): warn leader against double-triggering an agent
Squad coordinators were both @mentioning an agent in the parent issue and
creating a todo child issue assigned to the same agent, causing the agent
to be triggered twice in parallel (mention dispatch + assignment dispatch).
The server has no cross-issue dedupe for this case — and adding one would
make @mention semantics context-dependent and unpredictable.

Fix is at the prompt level: tell the squad leader that a `todo` child
issue with an agent assignee already fires that agent, so they must pick
exactly one delegation path for any given piece of work — comment-based
@mention or todo child-issue assignment, never both.

Adds a focused regression test that locks in the new rule via narrow
substring checks (so harmless rewording stays free).

Fixes #3033

Co-authored-by: multica-agent <github@multica.ai>
2026-05-22 13:46:38 +08:00
2 changed files with 26 additions and 1 deletions

View File

@@ -79,7 +79,14 @@ Hard rules:
explaining the gap (and @mention the issue's reporter if possible)
rather than silently doing the work.
- ALWAYS call ` + "`" + `multica squad activity` + "`" + ` before ending your turn —
even when the outcome is no_action.`
even when the outcome is no_action.
- A child issue you create with ` + "`" + `--status todo` + "`" + ` and an agent assignee
already fires that agent automatically — the assignment IS the trigger.
If you also @mention the same agent on this parent issue for the same
work, the agent runs twice in parallel (once from the mention, once
from the assignment). Pick exactly one path: either delegate by
@mention on this issue, or create a ` + "`" + `todo` + "`" + ` child issue assigned to
them. Never both for the same work.`
// buildSquadLeaderBriefing composes the full system briefing appended to a
// squad leader's Instructions when it claims a task on a squad-assigned

View File

@@ -13,6 +13,24 @@ import (
db "github.com/multica-ai/multica/server/pkg/db/generated"
)
// TestSquadOperatingProtocolWarnsAgainstDualTrigger locks in the rule
// added for #3033: the protocol must tell the squad leader that a `todo`
// child issue with an agent assignee already fires that agent, so they
// must not also @mention the same agent on the parent issue for the
// same work. Asserts behavior, not exact wording — keep the substrings
// narrow so harmless rewording doesn't break the test.
func TestSquadOperatingProtocolWarnsAgainstDualTrigger(t *testing.T) {
compact := strings.Join(strings.Fields(squadOperatingProtocol), " ")
for _, want := range []string{
"--status todo` and an agent assignee already fires that agent automatically",
"Never both for the same work.",
} {
if !strings.Contains(compact, want) {
t.Errorf("expected squad operating protocol to contain %q\n--- protocol ---\n%s", want, squadOperatingProtocol)
}
}
}
// seedSquadForBriefing creates a squad with the seeded test agent as
// leader. Returns the loaded db.Squad and a cleanup-registered ID.
func seedSquadForBriefing(t *testing.T, leaderID string, name, instructions string) db.Squad {