Files
multica/server/migrations/090_task_is_leader.up.sql
Jiayuan Zhang 4d6b5ad06f fix(squad): wake leader when dual-role agent posts as worker (MUL-2218) (#2626)
* fix(squad): wake leader when dual-role agent posts as worker (MUL-2218)

The squad-leader self-trigger guard skipped a comment whenever the
author equalled the squad's leader id, regardless of the role the agent
was acting in. For an agent that holds both leader and worker roles in
the same squad, this meant the leader role never reacted to its own
worker output and the issue stalled.

Tag each enqueued task with is_leader_task and consult the agent's
most recent task on the issue from both self-trigger guards (comment
path + @squad mention path) — skip only when that task was itself a
leader task.

Co-authored-by: multica-agent <github@multica.ai>

* fix(squad): inherit is_leader_task on retry task clone (MUL-2218)

CreateRetryTask cloned a parent task into a fresh queued attempt but
omitted is_leader_task from the column list, so the child silently fell
back to the column default (false). For a leader task that hit auto-retry
through MaybeRetryFailedTask, the retried task posed as a worker task —
the self-trigger guard then no longer recognised the leader's own
comments, re-opening the very loop MUL-2218 closes.

Inherit p.is_leader_task in the clone and add a query-level test that
covers both leader and worker retries.

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: multica-agent <github@multica.ai>
2026-05-14 15:23:36 +02:00

10 lines
598 B
SQL

-- agent_task_queue.is_leader_task marks a task as enqueued in the squad-leader
-- role. The squad-leader self-trigger guard previously skipped a comment
-- whenever its author equalled `squad.LeaderID`, which mis-fired for an agent
-- that is simultaneously a leader and a worker of the same squad: a comment
-- posted by the agent in its worker role never woke its leader role. The
-- guard now consults the agent's most recent task on the issue and skips
-- only when that task was itself a leader task.
ALTER TABLE agent_task_queue
ADD COLUMN is_leader_task BOOLEAN NOT NULL DEFAULT FALSE;