Skip to content

Commit 5f99b30

Browse files
dlorencTest Userclaude
authored
Notify merge-queue when workers complete PRs (#18)
Previously, when a worker completed (via `multiclaude agent complete`), only the supervisor was notified. The merge-queue had to rely on periodic 2-minute polling to discover new PRs. This fix ensures the merge-queue receives an immediate notification when workers complete, enabling faster PR processing. Changes: - daemon.go: handleCompleteAgent now sends completion messages to both supervisor and merge-queue - worker.md: Updated to reflect that merge-queue is also notified - merge-queue.md: Added new section about receiving completion notifications Fixes #16 Co-authored-by: Test User <test@example.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 385e3dc commit 5f99b30

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

internal/daemon/daemon.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,22 +646,32 @@ func (d *Daemon) handleCompleteAgent(req socket.Request) socket.Response {
646646

647647
d.logger.Info("Agent %s/%s marked as ready for cleanup", repoName, agentName)
648648

649-
// Notify supervisor that worker completed
649+
// Notify supervisor and merge-queue that worker completed
650650
if agent.Type == state.AgentTypeWorker {
651651
msgMgr := d.getMessageManager()
652652
task := agent.Task
653653
if task == "" {
654654
task = "unknown task"
655655
}
656-
messageBody := fmt.Sprintf("Worker '%s' has completed its task: %s", agentName, task)
657656

658-
if _, err := msgMgr.Send(repoName, agentName, "supervisor", messageBody); err != nil {
657+
// Notify supervisor
658+
supervisorMessage := fmt.Sprintf("Worker '%s' has completed its task: %s", agentName, task)
659+
if _, err := msgMgr.Send(repoName, agentName, "supervisor", supervisorMessage); err != nil {
659660
d.logger.Error("Failed to send completion message to supervisor: %v", err)
660661
} else {
661662
d.logger.Info("Sent completion notification to supervisor for worker %s", agentName)
662-
// Trigger immediate message delivery
663-
go d.routeMessages()
664663
}
664+
665+
// Notify merge-queue so it can process any new PRs immediately
666+
mergeQueueMessage := fmt.Sprintf("Worker '%s' has completed and may have created a PR. Task: %s. Please check for new PRs to process.", agentName, task)
667+
if _, err := msgMgr.Send(repoName, agentName, "merge-queue", mergeQueueMessage); err != nil {
668+
d.logger.Error("Failed to send completion message to merge-queue: %v", err)
669+
} else {
670+
d.logger.Info("Sent completion notification to merge-queue for worker %s", agentName)
671+
}
672+
673+
// Trigger immediate message delivery
674+
go d.routeMessages()
665675
}
666676

667677
// Trigger immediate cleanup check

internal/prompts/merge-queue.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ multiclaude agent send-message supervisor "Emergency fix mode RESOLVED: Main bra
6666

6767
Then resume normal merge queue operations.
6868

69+
## Worker Completion Notifications
70+
71+
When workers complete their tasks (by running `multiclaude agent complete`), you will
72+
receive a notification message automatically. This means:
73+
74+
- You'll be immediately informed when a worker may have created a new PR
75+
- You should check for new PRs when you receive a completion notification
76+
- Don't rely solely on periodic polling - respond promptly to notifications
77+
6978
## Commands
7079

7180
Use these commands to manage the merge queue:

internal/prompts/worker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Your work starts from the main branch in an isolated worktree.
1010
When you create a PR, use the branch name: multiclaude/<your-agent-name>
1111

1212
After creating your PR, signal completion with `multiclaude agent complete`.
13-
The supervisor will be notified immediately and your workspace will be cleaned up.
13+
The supervisor and merge-queue will be notified immediately, and your workspace will be cleaned up.
1414

1515
Your goal is to complete your task, or to get as close as you can while making incremental forward progress.
1616

0 commit comments

Comments
 (0)