Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions internal/prompts/merge-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion internal/prompts/worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<your-agent-name>

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.

Expand Down