diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index 5965fee..fab2417 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -646,22 +646,32 @@ func (d *Daemon) handleCompleteAgent(req socket.Request) socket.Response { d.logger.Info("Agent %s/%s marked as ready for cleanup", repoName, agentName) - // Notify supervisor that worker completed + // Notify supervisor and merge-queue that worker completed if agent.Type == state.AgentTypeWorker { msgMgr := d.getMessageManager() task := agent.Task if task == "" { task = "unknown task" } - messageBody := fmt.Sprintf("Worker '%s' has completed its task: %s", agentName, task) - if _, err := msgMgr.Send(repoName, agentName, "supervisor", messageBody); err != nil { + // Notify supervisor + supervisorMessage := fmt.Sprintf("Worker '%s' has completed its task: %s", agentName, task) + if _, err := msgMgr.Send(repoName, agentName, "supervisor", supervisorMessage); err != nil { d.logger.Error("Failed to send completion message to supervisor: %v", err) } else { d.logger.Info("Sent completion notification to supervisor for worker %s", agentName) - // Trigger immediate message delivery - go d.routeMessages() } + + // Notify merge-queue so it can process any new PRs immediately + mergeQueueMessage := fmt.Sprintf("Worker '%s' has completed and may have created a PR. Task: %s. Please check for new PRs to process.", agentName, task) + if _, err := msgMgr.Send(repoName, agentName, "merge-queue", mergeQueueMessage); err != nil { + d.logger.Error("Failed to send completion message to merge-queue: %v", err) + } else { + d.logger.Info("Sent completion notification to merge-queue for worker %s", agentName) + } + + // Trigger immediate message delivery + go d.routeMessages() } // Trigger immediate cleanup check diff --git a/internal/prompts/merge-queue.md b/internal/prompts/merge-queue.md index 5216d47..f30ea75 100644 --- a/internal/prompts/merge-queue.md +++ b/internal/prompts/merge-queue.md @@ -64,6 +64,15 @@ multiclaude agent send-message supervisor "Emergency fix mode RESOLVED: Main bra Then resume normal merge queue operations. +## Worker Completion Notifications + +When workers complete their tasks (by running `multiclaude agent complete`), you will +receive a notification message automatically. This means: + +- You'll be immediately informed when a worker may have created a new PR +- You should check for new PRs when you receive a completion notification +- Don't rely solely on periodic polling - respond promptly to notifications + ## Commands Use these commands to manage the merge queue: diff --git a/internal/prompts/worker.md b/internal/prompts/worker.md index c6cb48b..5e1dc44 100644 --- a/internal/prompts/worker.md +++ b/internal/prompts/worker.md @@ -10,7 +10,7 @@ Your work starts from the main branch in an isolated worktree. When you create a PR, use the branch name: multiclaude/ After creating your PR, signal completion with `multiclaude agent complete`. -The supervisor will be notified immediately and your workspace will be cleaned up. +The supervisor and merge-queue will be notified immediately, and your workspace will be cleaned up. Your goal is to complete your task, or to get as close as you can while making incremental forward progress.